-
- All Implemented Interfaces:
-
org.osmdroid.views.overlay.Overlay.Snappable
,org.osmdroid.views.util.constants.OverlayConstants
public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay implements Overlay.Snappable
Draws a list of 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().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ItemizedOverlay.OnFocusChangeListener
-
Constructor Summary
Constructors Constructor Description ItemizedOverlay(Context ctx, Drawable pDefaultMarker)
Use ItemizedOverlay instead ItemizedOverlay(Drawable pDefaultMarker)
-
Method Summary
Modifier and Type Method Description abstract int
size()
The number of items in this overlay. int
getDrawnItemsLimit()
void
setDrawnItemsLimit(int aLimit)
void
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown. void
draw(Canvas canvas, Projection pj)
Draw a marker on each of our items. final Item
getItem(int position)
Returns the Item at the given index. List<Item>
getDisplayedItems()
Get the list of all the items that are currently drawn on the canvas.The obvious use case is a "share" or "export" button on a map, restricted to what is displayed. boolean
onSingleTapConfirmed(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).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. Item
getFocus()
void
setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)
-
Methods inherited from class org.osmdroid.views.overlay.Overlay
draw, draw, getBounds, isEnabled, onDetach, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onPause, onResume, onScroll, onShowPress, onSingleTapConfirmed, onSingleTapUp, onTouchEvent, onTrackballEvent, setEnabled
-
Methods inherited from class org.osmdroid.views.overlay.Overlay.Snappable
onSnapToItem
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ItemizedOverlay
ItemizedOverlay(Context ctx, Drawable pDefaultMarker)
Use ItemizedOverlay instead
-
ItemizedOverlay
ItemizedOverlay(Drawable pDefaultMarker)
-
-
Method Detail
-
size
abstract int size()
The number of items in this overlay.
-
getDrawnItemsLimit
int getDrawnItemsLimit()
-
setDrawnItemsLimit
void setDrawnItemsLimit(int aLimit)
-
onDetach
void onDetach(MapView mapView)
Override to perform clean up of resources before shutdown. By default does nothing.
-
draw
void draw(Canvas canvas, Projection pj)
Draw a marker on each of our items. populate() must have been called first.The marker will be drawn twice for each Item in the Overlay--once in the shadow phase, skewedand darkened, then again in the non-shadow phase. The bottom-center of the marker will bealigned with the geographical coordinates of the Item.The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item mayprovide an alternate marker via its OverlayItem.getMarker(int) method. If that method returnsnull, the default marker is used.The focused item is always drawn last, which puts it visually on top of the other items.
-
getItem
final Item getItem(int position)
Returns the Item at the given index.
- Parameters:
position
- the position of the item to return
-
getDisplayedItems
List<Item> getDisplayedItems()
Get the list of all the items that are currently drawn on the canvas.The obvious use case is a "share" or "export" button on a map, restricted to what is displayed.The order of the items is kept
-
onSingleTapConfirmed
boolean onSingleTapConfirmed(MotionEvent e, MapView mapView)
By default does nothing (
{@code return false}
). If you handled the Event, return{@code true}
, otherwise return{@code false}
. If you returned{@code true}
none of the following Overlaysor the underlying MapView has the chance to handle this event.
-
setDrawFocusedItem
void setDrawFocusedItem(boolean drawFocusedItem)
Set whether or not to draw the focused item. The default is to draw it, but some clients mayprefer to draw the focused item themselves.
-
setFocus
void setFocus(Item item)
If the given Item is found in the overlay, force it to be the current focus-bearer. Anyregistered OnFocusChangeListener will be notified. This does not move the map, so ifthe Item isn't already centered, the user may get confused. If the Item is not found, this isa no-op. You can also pass null to remove focus.
-
setOnFocusChangeListener
void setOnFocusChangeListener(ItemizedOverlay.OnFocusChangeListener l)
-
-
-
-