Item
- public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay implements Overlay.Snappable
OverlayItem
as markers to a map. The item with the lowest index is drawn
as last and therefore the 'topmost' marker. It also gets checked for onTap first. This class is
generic, because you then you get your custom item-class passed back in onTap().Modifier and Type | Class and Description |
---|---|
static interface |
ItemizedOverlay.OnFocusChangeListener |
Overlay.Snappable
Modifier and Type | Field and Description |
---|---|
protected Drawable |
mDefaultMarker |
protected boolean |
mDrawFocusedItem |
protected int |
mDrawnItemsLimit |
mBounds, SHADOW_X_SKEW, SHADOW_Y_SCALE
DEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET
Constructor and Description |
---|
ItemizedOverlay(Context ctx,
Drawable pDefaultMarker)
Deprecated.
|
ItemizedOverlay(Drawable pDefaultMarker) |
Modifier and Type | Method and Description |
---|---|
protected Drawable |
boundToHotspot(Drawable marker,
OverlayItem.HotspotPlace hotspot)
Adjusts a drawable's bounds so that (0,0) is a pixel in the location described by the hotspot
parameter.
|
protected Rect |
calculateItemRect(Item item,
Point coords,
Rect reuse)
Calculates the screen rect for an item.
|
protected abstract Item |
createItem(int i)
Method by which subclasses create the actual Items.
|
void |
draw(Canvas canvas,
Projection pj)
Draw a marker on each of our items.
|
protected Drawable |
getDefaultMarker(int state) |
List<Item> |
getDisplayedItems()
Get the list of all the items that are currently drawn on the canvas.
|
int |
getDrawnItemsLimit() |
Item |
getFocus() |
Item |
getItem(int position)
Returns the Item at the given index.
|
protected boolean |
hitTest(Item item,
Drawable marker,
int hitX,
int hitY)
See if a given hit point is within the bounds of an item's marker.
|
protected boolean |
isEventOnItem(Item pItem,
int pEventX,
int pEventY,
MapView pMapView) |
void |
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown.
|
protected boolean |
onDrawItem(Canvas canvas,
Item item,
Point curScreenCoords,
Projection pProjection)
Draws an item located at the provided screen coordinates to the canvas.
|
boolean |
onSingleTapConfirmed(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
protected boolean |
onTap(int index)
Override this method to handle a "tap" on an item.
|
protected void |
populate()
Utility method to perform all processing on a new ItemizedOverlay.
|
void |
setDrawFocusedItem(boolean drawFocusedItem)
Set whether or not to draw the focused item.
|
void |
setDrawnItemsLimit(int aLimit) |
void |
setFocus(Item item)
If the given Item is found in the overlay, force it to be the current focus-bearer.
|
void |
setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l) |
abstract int |
size()
The number of items in this overlay.
|
draw, drawAt, getBounds, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onPause, onResume, onScroll, onShowPress, onSingleTapUp, onTouchEvent, onTrackballEvent, setEnabled
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onSnapToItem
protected int mDrawnItemsLimit
protected final Drawable mDefaultMarker
protected boolean mDrawFocusedItem
@Deprecated public ItemizedOverlay(Context ctx, Drawable pDefaultMarker)
ItemizedOverlay(Drawable)
insteadpublic ItemizedOverlay(Drawable pDefaultMarker)
protected abstract Item createItem(int i)
public abstract int size()
public int getDrawnItemsLimit()
public void setDrawnItemsLimit(int aLimit)
public void onDetach(MapView mapView)
Overlay
public void draw(Canvas canvas, Projection pj)
protected final void populate()
public final Item getItem(int position)
position
- the position of the item to returnprotected boolean onDrawItem(Canvas canvas, Item item, Point curScreenCoords, Projection pProjection)
canvas
- what the item is drawn uponitem
- the item to be drawncurScreenCoords
- pProjection
- public List<Item> getDisplayedItems()
protected Drawable getDefaultMarker(int state)
protected boolean hitTest(Item item, Drawable marker, int hitX, int hitY)
item
- the item to hit testmarker
- the item's markerhitX
- x coordinate of point to checkhitY
- y coordinate of point to checkpublic boolean onSingleTapConfirmed(MotionEvent e, MapView mapView)
Overlay
return false
). If you handled the Event, return true
, otherwise return false
. If you returned true
none of the following Overlays
or the underlying MapView
has the chance to handle this event.onSingleTapConfirmed
in class Overlay
protected boolean onTap(int index)
public void setDrawFocusedItem(boolean drawFocusedItem)
public void setFocus(Item item)
ItemizedOverlay.OnFocusChangeListener
will be notified. This does not move the map, so if
the Item isn't already centered, the user may get confused. If the Item is not found, this is
a no-op. You can also pass null to remove focus.public Item getFocus()
protected Drawable boundToHotspot(Drawable marker, OverlayItem.HotspotPlace hotspot)
marker
- the drawable to adjusthotspot
- the hotspot for the drawableprotected Rect calculateItemRect(Item item, Point coords, Rect reuse)
item
- coords
- reuse
- public void setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)