public abstract class

AbstractListOverlay

extends Overlay
java.lang.Object
   ↳ com.google.android.maps.Overlay
     ↳ sofia.maps.AbstractListOverlay<Item>
Known Direct Subclasses

Class Overview

An abstract overlay that supports displaying elements in a list of arbitrary objects. These objects can have annotations on methods to provide marker information (ProvidesMarkerGeoPoint, ProvidesMarkerTitle, etc.), or alternatively a "decorator" object can be specified that provides this information given an item on the map.

AbstractListOverlay provides no rendering of its own, only methods by which subclasses can access the decorations for the items that should be displayed on the map. Sofia comes with two concrete subclasses that should be suitable for most users:

  • MarkerOverlay: displays each of the items in the list as a marker or "pin" on the map
  • RouteOverlay: treats the items in the list as a sequence of waypoints or stops and draws a line that connects them

This class provides support for displaying an informational "balloon" containing the title and content of the item when it is tapped, but it is disabled by default for this class. The MarkerOverlay class enables it by default, and the RouteOverlay class leaves is disabled. Custom subclasses that want to enable this functionality should call setShowsBalloonWhenClicked(boolean).

Event Handling

Users can implement the following methods in the context that owns this overlay's MapView (for example, their MapScreen class) to receive event notifications:

[void|boolean] mapItemWasClicked(Item item)
Called when the user clicks the location on the map representing one of the items in the list. The type of the "item" parameter must be compatible with the type of objects in the overlay's list. If this method is boolean and returns true, the event is assumed to be "consumed" and the default balloon popup will not appear.
void mapBalloonWasClicked(Item item)
Called when the balloon popup attached to the specified item is clicked. The type of the "item" parameter must be compatible with the type of objects in the overlay's list.

Summary

Nested Classes
class AbstractListOverlay.AnnotationDecorator  
[Expand]
Inherited Constants
From class com.google.android.maps.Overlay
Fields
protected static final AbstractListOverlay.AnnotationDecorator defaultDecorator
Public Constructors
AbstractListOverlay(MapView mapView, List<Item> list)
Initializes a new AbstractListOverlay.
Public Methods
Object getDecorator()
List<Item> getList()
Gets the list of objects to display in the overlay.
MapView getMapView()
Gets the MapView on which this overlay will be displayed.
boolean onTap(GeoPoint tapPoint, MapView mapView)
void setDecorator(Object decorator)
void setList(List<Item> newList)
Sets the list of objects to display in the overlay.
void setShowsBalloonWhenClicked(boolean showBalloon)
boolean showsBalloonWhenClicked()
Protected Methods
Rect getItemBounds(Point point, Item item)
Object getItemContent(Item item)
GeoPoint getItemGeoPoint(Item item)
String getItemTitle(Item item)
boolean hitTest(GeoPoint tapPoint, GeoPoint queryPoint, Item item)
Determines if the specified geopoint falls anywhere within the bounds of the marker image.
void openBalloon(GeoPoint geoPoint, Item item)
[Expand]
Inherited Methods
From class com.google.android.maps.Overlay
From class java.lang.Object

Fields

protected static final AbstractListOverlay.AnnotationDecorator defaultDecorator

Public Constructors

public AbstractListOverlay (MapView mapView, List<Item> list)

Initializes a new AbstractListOverlay.

Parameters
mapView the MapView to which this overlay will be added
list the list of objects to display in the overlay

Public Methods

public Object getDecorator ()

public List<Item> getList ()

Gets the list of objects to display in the overlay.

Returns
  • the list of objects to display in the overlay

public MapView getMapView ()

Gets the MapView on which this overlay will be displayed.

Returns
  • the MapView containing this overlay

public boolean onTap (GeoPoint tapPoint, MapView mapView)

public void setDecorator (Object decorator)

public void setList (List<Item> newList)

Sets the list of objects to display in the overlay. Calling this method will automatically repaint the map view; you do not need to do so separately.

Parameters
newList the new list of objects to display in the overlay

public void setShowsBalloonWhenClicked (boolean showBalloon)

public boolean showsBalloonWhenClicked ()

Protected Methods

protected Rect getItemBounds (Point point, Item item)

protected Object getItemContent (Item item)

protected GeoPoint getItemGeoPoint (Item item)

protected String getItemTitle (Item item)

protected boolean hitTest (GeoPoint tapPoint, GeoPoint queryPoint, Item item)

Determines if the specified geopoint falls anywhere within the bounds of the marker image.

Returns
  • true if the geopoint is within the bounds of the marker image, otherwise false

protected void openBalloon (GeoPoint geoPoint, Item item)