public abstract class Overlay extends Object implements OverlayConstants
Overlay
: Base class representing an overlay which may be displayed on top of a MapView
.
To add an overlay, subclass this class, create an instance, and add it to the list obtained from
getOverlays() of MapView
.
This class implements a form of Gesture Handling similar to
GestureDetector.SimpleOnGestureListener
and
GestureDetector.OnGestureListener
. The difference is there is an additional argument for
the item.
Modifier and Type | Class and Description |
---|---|
static interface |
Overlay.Snappable
Interface definition for overlays that contain items that can be snapped to (for example,
when the user invokes a zoom, this could be called allowing the user to snap the zoom to an
interesting point.)
|
Modifier and Type | Field and Description |
---|---|
protected BoundingBox |
mBounds |
protected static float |
SHADOW_X_SKEW |
protected static float |
SHADOW_Y_SCALE |
DEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET
Constructor and Description |
---|
Overlay() |
Overlay(Context ctx)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas pCanvas,
MapView pMapView,
boolean pShadow)
Draw the overlay over the map.
|
void |
draw(Canvas pCanvas,
Projection pProjection) |
protected static void |
drawAt(Canvas canvas,
Drawable drawable,
int x,
int y,
boolean shadow,
float aMapOrientation)
Convenience method to draw a Drawable at an offset.
|
BoundingBox |
getBounds()
Gets the bounds of the overlay, useful for skipping draw cycles on overlays
that are not in the current bounding box of the view
|
protected static int |
getSafeMenuId()
Since the menu-chain will pass through several independent Overlays, menu IDs cannot be fixed
at compile time.
|
protected static int |
getSafeMenuIdSequence(int count)
Similar to
getSafeMenuId() , except this reserves a sequence of IDs of length
count . |
boolean |
isEnabled()
Specifies if the Overlay is marked to be enabled.
|
void |
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown.
|
boolean |
onDoubleTap(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onDoubleTapEvent(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onDown(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onFling(MotionEvent pEvent1,
MotionEvent pEvent2,
float pVelocityX,
float pVelocityY,
MapView pMapView)
By default does nothing (
return false ). |
boolean |
onKeyDown(int keyCode,
KeyEvent event,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onKeyUp(int keyCode,
KeyEvent event,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onLongPress(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
void |
onPause()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriately
related issue https://github.com/osmdroid/osmdroid/issues/823
https://github.com/osmdroid/osmdroid/issues/806
|
void |
onResume()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriately
related issue https://github.com/osmdroid/osmdroid/issues/823
https://github.com/osmdroid/osmdroid/issues/806
|
boolean |
onScroll(MotionEvent pEvent1,
MotionEvent pEvent2,
float pDistanceX,
float pDistanceY,
MapView pMapView)
By default does nothing (
return false ). |
void |
onShowPress(MotionEvent pEvent,
MapView pMapView) |
boolean |
onSingleTapConfirmed(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onSingleTapUp(MotionEvent e,
MapView mapView)
By default does nothing (
return false ). |
boolean |
onTouchEvent(MotionEvent event,
MapView mapView)
You can prevent all(!) other Touch-related events from happening!
By default does nothing ( return false ). |
boolean |
onTrackballEvent(MotionEvent event,
MapView mapView)
By default does nothing (
return false ). |
void |
setEnabled(boolean pEnabled)
Sets whether the Overlay is marked to be enabled.
|
protected static final float SHADOW_X_SKEW
protected static final float SHADOW_Y_SCALE
protected BoundingBox mBounds
@Deprecated public Overlay(Context ctx)
Overlay()
insteadpublic Overlay()
public BoundingBox getBounds()
public void setEnabled(boolean pEnabled)
public boolean isEnabled()
protected static final int getSafeMenuId()
protected static final int getSafeMenuIdSequence(int count)
getSafeMenuId()
, except this reserves a sequence of IDs of length
count
. The returned number is the starting index of that sequential list.getSafeMenuId()
public void draw(Canvas pCanvas, MapView pMapView, boolean pShadow)
draw(Canvas, Projection)
instead (cf. MapSnapshot
public void draw(Canvas pCanvas, Projection pProjection)
public void onDetach(MapView mapView)
public boolean onKeyDown(int keyCode, KeyEvent event, MapView mapView)
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.public boolean onKeyUp(int keyCode, KeyEvent event, MapView mapView)
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.public boolean onTouchEvent(MotionEvent event, MapView mapView)
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.public boolean onTrackballEvent(MotionEvent event, MapView mapView)
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.public boolean onDoubleTap(MotionEvent e, MapView mapView)
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.public boolean onDoubleTapEvent(MotionEvent e, MapView mapView)
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.public boolean onSingleTapConfirmed(MotionEvent e, MapView mapView)
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.public boolean onDown(MotionEvent e, MapView mapView)
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.public boolean onFling(MotionEvent pEvent1, MotionEvent pEvent2, float pVelocityX, float pVelocityY, MapView pMapView)
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.public boolean onLongPress(MotionEvent e, MapView mapView)
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.public boolean onScroll(MotionEvent pEvent1, MotionEvent pEvent2, float pDistanceX, float pDistanceY, MapView pMapView)
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.public void onShowPress(MotionEvent pEvent, MapView pMapView)
public boolean onSingleTapUp(MotionEvent e, MapView mapView)
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.protected static void drawAt(Canvas canvas, Drawable drawable, int x, int y, boolean shadow, float aMapOrientation)
shadow
- If true, draw only the drawable's shadow. Otherwise, draw the drawable itself.aMapOrientation
- public void onPause()
public void onResume()