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 |
protected float |
scaleX |
protected float |
scaleY |
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 abstract Item |
createItem(int i)
Method by which subclasses create the actual Items.
|
void |
draw(Canvas canvas,
MapView mapView,
boolean shadow)
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.
|
void |
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown.
|
protected boolean |
onDrawItem(Canvas canvas,
Item item,
Point curScreenCoords,
MapView mapView)
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.
|
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
protected float scaleX
protected float scaleY
@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, MapView mapView, boolean shadow)
draw
in class Overlay
canvas
- the Canvas upon which to draw. Note that this may already have a transformation
applied, so be sure to leave it the way you found itmapView
- the MapView that requested the draw. Use MapView.getProjection() to convert
between on-screen pixels and latitude/longitude pairsshadow
- if true, draw the shadow layer. If false, draw the overlay contents.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, MapView mapView)
canvas
- what the item is drawn uponitem
- the item to be drawncurScreenCoords
- mapView
- 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 drawablepublic void setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)