com.esri.android.map
Class Callout

java.lang.Object
  extended by com.esri.android.map.Callout

public class Callout
extends Object

The CalloutView class draws a callout window and manages its behavior. By default the callout window will have a width of 150 pixels and height of 60 pixels. This view will automatically be stretched up to 300 pixels (by default, customizable using setMaxWidth(int)) by 150 pixels (by default, customizable using setMaxHeight(int)) to accommodate the content that is to appear inside of the callout window. The callout will automatically add scroll bars to the CalloutView to allow a user to scroll and view the content within.

By default, the callout window is empty and it is likely that you will want to work with the setContent(View) method to populate the callout window with some Android View (for example, TextView).

When the anchor position is set to ANCHOR_POSITION_FLOATING, the callout window will automatically adjust itself to try to remain on the device's screen when panning. Use the CalloutStyle.setAnchor(int) method and pass in one of the ANCHOR POSITION static fields to set the position of the anchor relatively to the callout window.

When the callout window is displayed, it is anchored to a location. This location is defined by the developer by calling the setCoordinates(Point) method, where a point is passed in. This point must have coordinates supplied in the MapView's spatial coordinate system. See the MapView for convenience methods to convert screen pixels to map coordinates, or to obtain the spatial coordinate system used by the MapView, as needed.

The callout's look and feel can be customized by creating a XML file in the res/xml folder of your application. The XML must have the following format:

 <?xml version="1.0" encoding="utf-8"?>
  <resources>
      <calloutViewStyle
         titleTextColor="#000000" <!-- some RGB color or a reference to a color />
         titleTextSize = 10; <!-- size of the title text in scaled pixels (based on screen density and user font size preference) />
         titleTextStyle = 0; <!-- See the class Typeface in the Android SDK for available values />
         titleTextTypeFace = 0; <!-- See the class Typeface in the Android SDK for available values /> 
          backgroundColor="#ffffff" <!-- some RGB color or a reference to a color />
          backgroundAlpha="255" <!-- 0(transparent) to 255(opaque) />
          frameColor="#000000" <!-- some RGB color or a reference to a color />
          flat="true" <!-- draws a 3D frame />
          style.getCornerCurve()="0"   <!-- the radius of the window's corners' curvature (max=40) />
          anchor="5" /> <!-- the position of the anchor (0-8, see ANCHOR_POSITION_XXX constants) /> 
   </resources>
 
 
Once this file has been created, you can either use setStyle(int) and pass it the reference of the file (R.xml.MyXmlFileName) or declare an attribut "calloutStyle" for the MapView in your layout. e.g.:
 <com.esri.android.map.MapView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/mapview" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     calloutStyle="@xml/style3">
 


Field Summary
static int ANCHOR_POSITION_FLOATING
          Positions the anchor in the best position that will keep the callout window as much as possible on the screen when panning or zooming
static int ANCHOR_POSITION_LEFT_MIDDLE
          Positions the anchor at the left center of the callout window
static int ANCHOR_POSITION_LOWER_LEFT_CORNER
          Positions the anchor at the bottom left corner of the callout window
static int ANCHOR_POSITION_LOWER_MIDDLE
          Positions the anchor at the bottom center of the callout window
static int ANCHOR_POSITION_LOWER_RIGHT_CORNER
          Positions the anchor at the bottom right corner of the callout window
static int ANCHOR_POSITION_RIGHT_MIDDLE
          Positions the anchor at the right center of the callout window
static int ANCHOR_POSITION_UPPER_LEFT_CORNER
          Positions the anchor at the top left corner of the callout window
static int ANCHOR_POSITION_UPPER_MIDDLE
          Positions the anchor at the top center of the callout window
static int ANCHOR_POSITION_UPPER_RIGHT_CORNER
          Positions the anchor at the top right corner of the callout window
 
Constructor Summary
Callout(MapView map)
          Constructor taking in MapView on which the callout window will be displayed.
 
Method Summary
 void animatedHide()
          Hides the callout window with animation.
 void animatedShow(Point coordinates, android.view.View newContent)
          Displays the callout window with animation at the given coordinates with the provided content.
 Point getCoordinates()
          Returns the map coordinates of the anchor point.
 int getMaxHeight()
          Returns the maximum height the callout window can stretch.
 int getMaxWidth()
          Returns the maximum width the callout window can stretch.
 int[] getOffset()
          Returns an array of 2 integer values representing respectively the vertical and the horizontal offset of the anchor point relatively to the coordinates set for the anchor.
 CalloutStyle getStyle()
          Returns the style of current callout.
 void hide()
          Hides the callout window.
 boolean isShowing()
          Returns whether the callout is currently displayed or not.
 void move(Point newCoordinates)
          Moves the callout window to the provided coordinates.
 void refresh()
          This method refreshes the content of the callout window for the content's change or update.
 void setContent(android.view.View v)
          Sets the content of the callout window to display in callout window.
 void setCoordinates(Point coordinates)
          Sets the anchor of the callout window to the given point in the map spatial reference.
 void setMaxHeight(int maxHeight)
          Sets the maximum height the callout window can stretch to.
 void setMaxWidth(int maxWidth)
          Sets the maximum width the callout window can stretch to.
 void setOffset(int x, int y)
          Sets the vertical and the horizontal offset of the anchor point relatively to the coordinates set for the anchor.
 void setStyle(CalloutStyle style)
          Sts the style of the callout
 void setStyle(int xmlId)
           Sets the style of the callout window from an XML resource id.
 void show()
          Displays the callout window.
 void show(Point coordinates)
          Displays the callout window at the given point in the spatial reference of map view.
 void show(Point coordinates, android.view.View newContent)
          Displays the callout window at the given point with the provided content.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCHOR_POSITION_UPPER_LEFT_CORNER

public static final int ANCHOR_POSITION_UPPER_LEFT_CORNER
Positions the anchor at the top left corner of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_UPPER_MIDDLE

public static final int ANCHOR_POSITION_UPPER_MIDDLE
Positions the anchor at the top center of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_UPPER_RIGHT_CORNER

public static final int ANCHOR_POSITION_UPPER_RIGHT_CORNER
Positions the anchor at the top right corner of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_RIGHT_MIDDLE

public static final int ANCHOR_POSITION_RIGHT_MIDDLE
Positions the anchor at the right center of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_LOWER_RIGHT_CORNER

public static final int ANCHOR_POSITION_LOWER_RIGHT_CORNER
Positions the anchor at the bottom right corner of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_LOWER_MIDDLE

public static final int ANCHOR_POSITION_LOWER_MIDDLE
Positions the anchor at the bottom center of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_LOWER_LEFT_CORNER

public static final int ANCHOR_POSITION_LOWER_LEFT_CORNER
Positions the anchor at the bottom left corner of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_LEFT_MIDDLE

public static final int ANCHOR_POSITION_LEFT_MIDDLE
Positions the anchor at the left center of the callout window

See Also:
Constant Field Values

ANCHOR_POSITION_FLOATING

public static final int ANCHOR_POSITION_FLOATING
Positions the anchor in the best position that will keep the callout window as much as possible on the screen when panning or zooming

See Also:
Constant Field Values
Constructor Detail

Callout

public Callout(MapView map)
Constructor taking in MapView on which the callout window will be displayed.

Parameters:
map - the MapView on which this callout will display.
Method Detail

getCoordinates

public Point getCoordinates()
Returns the map coordinates of the anchor point.

Returns:
the coordinates of the anchor point

getMaxWidth

public int getMaxWidth()
Returns the maximum width the callout window can stretch.

Returns:
the maximum width of the callout window.

getMaxHeight

public int getMaxHeight()
Returns the maximum height the callout window can stretch.

Returns:
the maximum height of the callout window.

getOffset

public int[] getOffset()
Returns an array of 2 integer values representing respectively the vertical and the horizontal offset of the anchor point relatively to the coordinates set for the anchor.

Returns:
the offset an array of 2 integer values for vertical and horizontal offset.

getStyle

public CalloutStyle getStyle()
Returns the style of current callout.

Returns:
the style of current callout

setOffset

public void setOffset(int x,
                      int y)
Sets the vertical and the horizontal offset of the anchor point relatively to the coordinates set for the anchor.

Parameters:
x - the vertical offset to set
y - the horizontal offset to set

setMaxWidth

public void setMaxWidth(int maxWidth)
Sets the maximum width the callout window can stretch to.

Parameters:
maxWidth - the maximum width to set for the callout window

setMaxHeight

public void setMaxHeight(int maxHeight)
Sets the maximum height the callout window can stretch to.

Parameters:
maxHeight - the maximum height to set for the callout window

show

public void show()
Displays the callout window.


show

public void show(Point coordinates)
Displays the callout window at the given point in the spatial reference of map view. call.

Parameters:
coordinates - the coordinates of the anchor point

show

public void show(Point coordinates,
                 android.view.View newContent)
Displays the callout window at the given point with the provided content.

Parameters:
coordinates - the point of the anchor
newContent - the content of the callout window

animatedShow

public void animatedShow(Point coordinates,
                         android.view.View newContent)
Displays the callout window with animation at the given coordinates with the provided content.

Parameters:
coordinates - the coordinates of the anchor point
newContent - the content of the callout window

hide

public void hide()
Hides the callout window.


animatedHide

public void animatedHide()
Hides the callout window with animation.


move

public void move(Point newCoordinates)
Moves the callout window to the provided coordinates.

Parameters:
newCoordinates - the new coordinates of the anchor point of the callout window

setStyle

public void setStyle(int xmlId)

Sets the style of the callout window from an XML resource id.

Parameters:
xmlId - the android ID of the XML style for the callout window

setStyle

public void setStyle(CalloutStyle style)
Sts the style of the callout

Parameters:
style -

setCoordinates

public void setCoordinates(Point coordinates)
Sets the anchor of the callout window to the given point in the map spatial reference.

Parameters:
coordinates - of the point the anchor is to set

setContent

public void setContent(android.view.View v)
Sets the content of the callout window to display in callout window.

Parameters:
v - the view to display in the callout window

isShowing

public boolean isShowing()
Returns whether the callout is currently displayed or not.

Returns:
true if the callout is displayed. false otherwise.

refresh

public void refresh()
This method refreshes the content of the callout window for the content's change or update. Typically this method is invoked after the setContent() method is called.



Copyright © 2012. All Rights Reserved.