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 and manages the behavior of a callout window. 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). In addition, the callout window will not have a title. You can work with the setTitle(String) method to add one to the callout window.


When the anchor position is set to ANCHOR_POSITION_FLOATING, the callout window will automatically re-adjust to try and remain on the device's screen when panning. Use the 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 do conversions from one screen pixels to screen coordinates, or to obtain the spatial coordinate system being used by the MapView, as needed.


The callout 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:

 <resources>
 <calloutViewStyle
   titleTextColor="#000000" // some RGB color or a reference to a color
   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 
   cornerCurve="0"   // the radius of the window's corners' curvature (max=40)
   anchor="5" /> // the position of the anchor (0-9, 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">
 


Nested Class Summary
protected  class Callout.CalloutInner
           
 
Field Summary
static int ANCHOR_MOVE_DOWN
          Move the anchor downwards e.g.
static int ANCHOR_MOVE_LEFT
          Move the anchor to the left e.g.
static int ANCHOR_MOVE_RIGHT
          Move the anchor to the right e.g.
static int ANCHOR_MOVE_UP
          Move the anchor upwards e.g.
static int ANCHOR_POSITION_FLOATING
          Position 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
          Position the anchor at the left center of the callout window
static int ANCHOR_POSITION_LOWER_LEFT_CORNER
          Position the anchor at the bottom left corner of the callout window
static int ANCHOR_POSITION_LOWER_MIDDLE
          Position the anchor at the bottom center of the callout window
static int ANCHOR_POSITION_LOWER_RIGHT_CORNER
          Position the anchor at the bottom right corner of the callout window
static int ANCHOR_POSITION_RIGHT_MIDDLE
          Position the anchor at the right center of the callout window
static int ANCHOR_POSITION_UPPER_LEFT_CORNER
          Position the anchor at the top left corner of the callout window
static int ANCHOR_POSITION_UPPER_MIDDLE
          Position the anchor at the top center of the callout window
static int ANCHOR_POSITION_UPPER_RIGHT_CORNER
          Position the anchor at the top right corner of the callout window
 
Constructor Summary
Callout(MapView map)
          Constructor taking in the MapView the callout window will be displayed on as a parameter.
 
Method Summary
 int getAnchor()
           Returns the position of the anchor as one of the following possible values.
 Point getCoordinates()
          Returns the map coordinates of the anchor point.
 int getMaxHeight()
          Returns the maximum height the callout window can stretch to.
 int getMaxWidth()
          Returns the maximum width the callout window can stretch to.
 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.
 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 invokes a refresh for the callout window when you need to refresh the contents because they have changed or been updated.
 void setAnchor(int anchor)
           Assigns the position of the anchor using one of the following possible values:
 void setContent(android.view.View v)
          Sets the content of the callout window.
 void setCoordinates(Point coordinates)
          Sets the coordinates of the anchor points 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(android.util.AttributeSet attrs)
          Gives a set of attributes to be applied as the callout style
 void setStyle(int xmlId)
          Sets the reference to the style of the callout window.
 void setTitle(String title)
          Assigns a title to the callout window dialog that is displayed on the device.
By default, the title is an empty String and will not display anything if this method is not invoked with a value.
 void show()
          Displays the callout window with whatever parameters are set at the time of the method call.
 void show(Point coordinates)
          Displays the callout window at the given coordinates with whatever parameters are set at the time of the method call.
 void show(Point coordinates, android.view.View newContent)
          Displays the callout window at the given coordinates with the provided content.
 void show(Point coordinates, android.view.View newContent, String newTitle)
          Displays the callout window at the given coordinates with the provided content and title.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCHOR_MOVE_DOWN

public static final int ANCHOR_MOVE_DOWN
Move the anchor downwards e.g. from ANCHOR_POSITION_LEFT_MIDDLE to ANCHOR_POSITION_LOWER_LEFT_CORNER

See Also:
Constant Field Values

ANCHOR_MOVE_UP

public static final int ANCHOR_MOVE_UP
Move the anchor upwards e.g. from ANCHOR_POSITION_LEFT_MIDDLE to ANCHOR_POSITION_UPPER_LEFT_CORNER

See Also:
Constant Field Values

ANCHOR_MOVE_LEFT

public static final int ANCHOR_MOVE_LEFT
Move the anchor to the left e.g. from ANCHOR_POSITION_UPPER_RIGHT_CORNER to ANCHOR_POSITION_UPPER_MIDDLE

See Also:
Constant Field Values

ANCHOR_MOVE_RIGHT

public static final int ANCHOR_MOVE_RIGHT
Move the anchor to the right e.g. from ANCHOR_POSITION_LOWER_LEFT_CORNER to ANCHOR_POSITION_LOWER_MIDDLE

See Also:
Constant Field Values

ANCHOR_POSITION_UPPER_LEFT_CORNER

public static final int ANCHOR_POSITION_UPPER_LEFT_CORNER
Position 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
Position 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
Position 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
Position 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
Position 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
Position 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
Position 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
Position 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
Position 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 the MapView the callout window will be displayed on as a parameter.

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

getCoordinates

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

Returns:
the coordinates

getAnchor

public int getAnchor()

Returns the position of the anchor as one of the following possible values.

  • ANCHOR_POSITION_UPPER_LEFT_CORNER
  • ANCHOR_POSITION_UPPER_MIDDLE
  • ANCHOR_POSITION_UPPER_RIGHT_CORNER
  • ANCHOR_POSITION_RIGHT_MIDDLE
  • ANCHOR_POSITION_LOWER_RIGHT_CORNER
  • ANCHOR_POSITION_LOWER_MIDDLE
  • ANCHOR_POSITION_LOWER_LEFT_CORNER
  • ANCHOR_POSITION_LEFT_MIDDLE
  • ANCHOR_POSITION_FLOATING

  • Returns:
    the anchor the current anchor of the callout window

    getMaxWidth

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

    Returns:
    the maxWidth the maximum width of the callout window.

    getMaxHeight

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

    Returns:
    the maxHeight 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.

    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

    setAnchor

    public void setAnchor(int anchor)

    Assigns the position of the anchor using one of the following possible values:

  • ANCHOR_POSITION_UPPER_LEFT_CORNER
  • ANCHOR_POSITION_UPPER_MIDDLE
  • ANCHOR_POSITION_UPPER_RIGHT_CORNER
  • ANCHOR_POSITION_RIGHT_MIDDLE
  • ANCHOR_POSITION_LOWER_RIGHT_CORNER
  • ANCHOR_POSITION_LOWER_MIDDLE
  • ANCHOR_POSITION_LOWER_LEFT_CORNER
  • ANCHOR_POSITION_LEFT_MIDDLE
  • ANCHOR_POSITION_FLOATING

  • Parameters:
    anchor - the anchor position to set

    show

    public void show()
    Displays the callout window with whatever parameters are set at the time of the method call.


    show

    public void show(Point coordinates)
    Displays the callout window at the given coordinates with whatever parameters are set at the time of the method 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 coordinates with the provided content.

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

    show

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

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

    hide

    public void hide()
    Hides the callout window.


    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 reference to the style of the callout window.

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

    setStyle

    public void setStyle(android.util.AttributeSet attrs)
    Gives a set of attributes to be applied as the callout style

    Parameters:
    attrs -

    setCoordinates

    public void setCoordinates(Point coordinates)
    Sets the coordinates of the anchor points in the map spatial reference.

    Parameters:
    coordinates - the coordinates to set

    setContent

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

    Parameters:
    v - the view to be displayed in the callout window

    setTitle

    public void setTitle(String title)
    Assigns a title to the callout window dialog that is displayed on the device.
    By default, the title is an empty String and will not display anything if this method is not invoked with a value.

    Parameters:
    title - the title to set for 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 invokes a refresh for the callout window when you need to refresh the contents because they have changed or been updated. Typically this method will be invoked after the setContent() method is called.



    Copyright © 2010. All Rights Reserved.