Item
- public abstract class ItemizedOverlay<Item extends OverlayItem> extends SafeDrawOverlay 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 android.graphics.drawable.Drawable |
mDefaultMarker |
protected boolean |
mDrawFocusedItem |
mResourceProxy, mScale, SHADOW_X_SKEW, SHADOW_Y_SCALE
DEBUGMODE, DEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET
Constructor and Description |
---|
ItemizedOverlay(android.graphics.drawable.Drawable pDefaultMarker,
ResourceProxy pResourceProxy) |
Modifier and Type | Method and Description |
---|---|
protected android.graphics.drawable.Drawable |
boundToHotspot(android.graphics.drawable.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.
|
protected void |
drawSafe(ISafeCanvas canvas,
MapView mapView,
boolean shadow)
Draw a marker on each of our items.
|
protected android.graphics.drawable.Drawable |
getDefaultMarker(int state) |
Item |
getFocus() |
Item |
getItem(int position)
Returns the Item at the given index.
|
protected boolean |
hitTest(Item item,
android.graphics.drawable.Drawable marker,
int hitX,
int hitY)
See if a given hit point is within the bounds of an item's marker.
|
protected void |
onDrawItem(ISafeCanvas canvas,
Item item,
android.graphics.Point curScreenCoords,
float aMapOrientation)
Draws an item located at the provided screen coordinates to the canvas.
|
boolean |
onSingleTapConfirmed(android.view.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 |
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, isUsingSafeCanvas, setUseSafeCanvas
drawAt, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDetach, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onScroll, onShowPress, onSingleTapUp, onTouchEvent, onTrackballEvent, setEnabled
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onSnapToItem
protected final android.graphics.drawable.Drawable mDefaultMarker
protected boolean mDrawFocusedItem
public ItemizedOverlay(android.graphics.drawable.Drawable pDefaultMarker, ResourceProxy pResourceProxy)
protected abstract Item createItem(int i)
public abstract int size()
protected void drawSafe(ISafeCanvas canvas, MapView mapView, boolean shadow)
drawSafe
in class SafeDrawOverlay
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 void onDrawItem(ISafeCanvas canvas, Item item, android.graphics.Point curScreenCoords, float aMapOrientation)
canvas
- what the item is drawn uponitem
- the item to be drawncurScreenCoords
- aMapOrientation
- protected android.graphics.drawable.Drawable getDefaultMarker(int state)
protected boolean hitTest(Item item, android.graphics.drawable.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(android.view.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 android.graphics.drawable.Drawable boundToHotspot(android.graphics.drawable.Drawable marker, OverlayItem.HotspotPlace hotspot)
marker
- the drawable to adjusthotspot
- the hotspot for the drawablepublic void setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)
Copyright © 2014. All Rights Reserved.