-
- All Implemented Interfaces:
-
org.osmdroid.views.util.constants.OverlayConstants
public abstract class Overlay 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 android.view.GestureDetector.SimpleOnGestureListener and GestureDetector.OnGestureListener. The difference is there is an additional argument for the item.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public 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 aninteresting point.)
-
Method Summary
Modifier and Type Method Description BoundingBox
getBounds()
Gets the bounds of the overlay, useful for skipping draw cycles on overlaysthat are not in the current bounding box of the view void
setEnabled(boolean pEnabled)
Sets whether the Overlay is marked to be enabled. boolean
isEnabled()
Specifies if the Overlay is marked to be enabled. void
draw(Canvas pCanvas, MapView pMapView, boolean pShadow)
Draw the overlay over the map. void
draw(Canvas pCanvas, Projection pProjection)
void
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown. boolean
onKeyDown(int keyCode, KeyEvent event, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onKeyUp(int keyCode, KeyEvent event, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onTouchEvent(MotionEvent event, MapView mapView)
You can prevent all(!) other Touch-related events from happening! boolean
onTrackballEvent(MotionEvent event, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onDoubleTap(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onDoubleTapEvent(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onSingleTapConfirmed(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onDown(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onFling(MotionEvent pEvent1, MotionEvent pEvent2, float pVelocityX, float pVelocityY, MapView pMapView)
By default does nothing ( {@code return false}
).boolean
onLongPress(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).boolean
onScroll(MotionEvent pEvent1, MotionEvent pEvent2, float pDistanceX, float pDistanceY, MapView pMapView)
By default does nothing ( {@code return false}
).void
onShowPress(MotionEvent pEvent, MapView pMapView)
boolean
onSingleTapUp(MotionEvent e, MapView mapView)
By default does nothing ( {@code return false}
).void
onPause()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github. void
onResume()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github. -
-
Method Detail
-
getBounds
BoundingBox getBounds()
Gets the bounds of the overlay, useful for skipping draw cycles on overlaysthat are not in the current bounding box of the view
-
setEnabled
void setEnabled(boolean pEnabled)
Sets whether the Overlay is marked to be enabled. This setting does nothing by default, butshould be checked before calling draw().
-
isEnabled
boolean isEnabled()
Specifies if the Overlay is marked to be enabled. This should be checked before callingdraw().
-
draw
void draw(Canvas pCanvas, MapView pMapView, boolean pShadow)
Draw the overlay over the map. This will be called on all active overlays with shadow=true,to lay down the shadow layer, and then again on all overlays with shadow=false. Callersshould check isEnabled() before calling draw(). By default, draws nothing.
changed for 5.6 to be public see https://github.com/osmdroid/osmdroid/issues/466If possible, use draw instead (cf. MapSnapshot
-
draw
void draw(Canvas pCanvas, Projection pProjection)
-
onDetach
void onDetach(MapView mapView)
Override to perform clean up of resources before shutdown. By default does nothing.
-
onKeyDown
boolean onKeyDown(int keyCode, KeyEvent event, 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.
-
onKeyUp
boolean onKeyUp(int keyCode, KeyEvent event, 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.
-
onTouchEvent
boolean onTouchEvent(MotionEvent event, MapView mapView)
You can prevent all(!) other Touch-related events from happening!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.
-
onTrackballEvent
boolean onTrackballEvent(MotionEvent event, 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.
-
onDoubleTap
boolean onDoubleTap(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.
-
onDoubleTapEvent
boolean onDoubleTapEvent(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.
-
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.
-
onDown
boolean onDown(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.
-
onFling
boolean onFling(MotionEvent pEvent1, MotionEvent pEvent2, float pVelocityX, float pVelocityY, MapView pMapView)
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.
-
onLongPress
boolean onLongPress(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.
-
onScroll
boolean onScroll(MotionEvent pEvent1, MotionEvent pEvent2, float pDistanceX, float pDistanceY, MapView pMapView)
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.
-
onShowPress
void onShowPress(MotionEvent pEvent, MapView pMapView)
-
onSingleTapUp
boolean onSingleTapUp(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.
-
onPause
void onPause()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github.com/osmdroid/osmdroid/issues/806
-
onResume
void onResume()
Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github.com/osmdroid/osmdroid/issues/806
-
-
-
-