public final class

Callout

extends Object
java.lang.Object
   ↳ com.esri.arcgisruntime.mapping.view.Callout

Class Overview

Draws a callout on a MapView and manages its behavior. A callout displays an Android View that contains text and/or other content. It has a leader that points to the location the callout refers to. The body of the callout is a rectangular area with curved corners that contains the content view provided by the application. A thin border line is drawn around the entire callout.

The application must get a Callout object from the MapView by calling getCallout(). This always returns the same object for a particular MapView. There are then four alternative ways to set the content and location and show the callout:

There are options to animate the drawing of the callout and to recenter the map when the callout is drawn. These can be configured by creating a Callout.ShowOptions object and passing it to the callout using setShowOptions(ShowOptions).

A number of style parameters can be configured by creating a Callout.Style object and passing it to the callout using setStyle(Style). These control how the callout looks, for example its size, color, and the size and position of the leader. There are two ways to set the parameters in the CalloutStyle, from Java code using setter methods or from an XML file. See Callout.Style for details.

Summary

Nested Classes
class Callout.ShowOptions Encapsulates a set of parameters that control how a callout is shown and dismissed. 
class Callout.Style Encapsulates a set of parameters that control how a callout looks. 
Public Methods
void dismiss()
Dismisses the callout, removing it from the screen.
View getContent()
Gets the content of the callout.
GeoElement getGeoElement()
Gets the GeoElement the callout relates to, if any.
Point getLocation()
Gets the location of the callout as a Point in map coordinates.
Callout.ShowOptions getShowOptions()
Gets the CalloutShowOptions object used by the callout.
Callout.Style getStyle()
Gets the CalloutStyle object used by the callout.
Point getTapLocation()
Gets the tap location associated with the callout if the callout is related to a GeoElement.
boolean isPassTouchEventsToMapView()
Returns whether or not touch events on the callout are passed up to the parent MapView.
boolean isShowing()
Returns whether or not the callout is currently shown.
void refresh()
Refreshes the content of the callout.
void setContent(View contentView)
Sets the content of the callout.
void setGeoElement(GeoElement geoElement, Point tapLocation)
Sets the location of the callout by specifying a GeoElement it relates to and an optional tap location.
void setLocation(Point location)
Sets the location of the callout by specifying a Point in map coordinates.
void setPassTouchEventsToMapView(boolean passToMapView)
Sets whether or not touch events on the callout are passed up to the parent MapView.
void setShowOptions(Callout.ShowOptions showOptions)
Sets options for how the callout is shown.
void setStyle(Callout.Style style)
Sets the style parameters used by the callout.
void show(View contentView, Point location)
Sets the content and location of the callout and shows it.
void show(View contentView, GeoElement geoElement, Point tapLocation)
Sets the content of the callout and shows it, with its location specified by a GeoElement it relates to and an optional tap location.
void show()
Shows the callout.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public void dismiss ()

Dismisses the callout, removing it from the screen. The way it is dismissed is controlled by Callout.ShowOptions which can be configured using setShowOptions(ShowOptions).

public View getContent ()

Gets the content of the callout.

Returns
  • the content View of the callout

public GeoElement getGeoElement ()

Gets the GeoElement the callout relates to, if any.

Returns
  • the GeoElement the callout relates to, or null if it's not related to a GeoElement

public Point getLocation ()

Gets the location of the callout as a Point in map coordinates. This is the Point the callout leader points to.

Returns
  • a Point that specifies the location of the callout in map coordinates, or null if no location has been specified

public Callout.ShowOptions getShowOptions ()

Gets the CalloutShowOptions object used by the callout.

Returns
  • an object specifying how the callout will be shown

public Callout.Style getStyle ()

Gets the CalloutStyle object used by the callout.

Returns
  • an object specifying style parameters used by the callout
See Also

public Point getTapLocation ()

Gets the tap location associated with the callout if the callout is related to a GeoElement.

Returns
  • the tap location that was specified together with a GeoElement the callout relates to, or null if the callout is not related to a GeoElement or if no tap location was specified

public boolean isPassTouchEventsToMapView ()

Returns whether or not touch events on the callout are passed up to the parent MapView.

Returns
  • true if touch events are passed to the parent MapView, false otherwise

public boolean isShowing ()

Returns whether or not the callout is currently shown.

Returns
  • true if the callout is shown, false otherwise

public void refresh ()

Refreshes the content of the callout. The application should call this method if it changes any of the Callout.Style parameters after showing the callout.

public void setContent (View contentView)

Sets the content of the callout.

Parameters
contentView the View to display in the callout
Throws
IllegalArgumentException if contentView is null

public void setGeoElement (GeoElement geoElement, Point tapLocation)

Sets the location of the callout by specifying a GeoElement it relates to and an optional tap location. If a tap location is specified, the callout location will be the nearest point to the tap location that lies within or on the GeoElement's geometry. If no tap location is specified, the callout location will be the position of the GeoElement (for Point geometries) or the point on the GeoElement's geometry that is closest to the center of its bounding envelope.

If the symbol associated with the GeoElement has a leader offset, that leader offset will be honored.

Parameters
geoElement the GeoElement the callout relates to
tapLocation a Point the user has tapped, or null if the callout is not associated with a tap
Throws
IllegalArgumentException if geoElement is null

public void setLocation (Point location)

Sets the location of the callout by specifying a Point in map coordinates. This is the Point the callout leader points to.

Parameters
location the Point at which to display the callout
Throws
IllegalArgumentException if location is null

public void setPassTouchEventsToMapView (boolean passToMapView)

Sets whether or not touch events on the callout are passed up to the parent MapView. The default value is true. Note that child Views of the callout may consume touch events upon them, for example clicks on a Button, in which case these touch events may not be passed to the callout or, in turn, to the MapView, regardless of this setting.

Parameters
passToMapView true to pass touch events to the parent MapView

public void setShowOptions (Callout.ShowOptions showOptions)

Sets options for how the callout is shown. For example if it appears immediately or with animation, and what happens if the location is not currently visible in the MapView.

Parameters
showOptions an object specifying how the callout will be shown
Throws
IllegalArgumentException if showOptions is null

public void setStyle (Callout.Style style)

Sets the style parameters used by the callout. These control how the callout looks, for example its size, color, and the size and position of the leader.

Parameters
style an object specifying style parameters used by the callout
Throws
IllegalArgumentException if style is null

public void show (View contentView, Point location)

Sets the content and location of the callout and shows it. The way it is shown is controlled by Callout.ShowOptions which can be configured using setShowOptions(ShowOptions).

Parameters
contentView the View to display in the callout; replaces any View that may have been set by setContent(View)
location the Point at which to display the callout; replaces any Point that may have been set by setLocation(Point)
Throws
IllegalArgumentException if contentView or location is null

public void show (View contentView, GeoElement geoElement, Point tapLocation)

Sets the content of the callout and shows it, with its location specified by a GeoElement it relates to and an optional tap location. If a tap location is specified, the callout location will be the nearest point to the tap location that lies within or on the GeoElement's geometry. If no tap location is specified, the callout location will be the position of the GeoElement (for Point geometries) or the point on the GeoElement's geometry that is closest to the center of its bounding envelope.

If the symbol associated with the GeoElement has a leader offset, that leader offset will be honored.

The way the callout is shown is controlled by Callout.ShowOptions which can be configured using setShowOptions(ShowOptions).

Parameters
contentView the View to display in the callout; replaces any View that may have been set by setContent(View)
geoElement the GeoElement the callout relates to; replaces any GeoElement that may have been set by setGeoElement(GeoElement, Point)
tapLocation a Point the user has tapped, or null if the callout is not associated with a tap; replaces any tap location that may have been set by setGeoElement(GeoElement, Point)
Throws
IllegalArgumentException if contentView or geoElement is null

public void show ()

Shows the callout. The way it is shown is controlled by Callout.ShowOptions which can be configured using setShowOptions(ShowOptions).

Throws
IllegalStateException if content has not been set, or if neither location nor GeoElement has been set