
public class CompassOverlay extends Overlay implements IOverlayMenuProvider, IOrientationConsumer
Note: this class can cause issues if you're also relying on MapView.addOnFirstLayoutListener(org.osmdroid.views.MapView.OnFirstLayoutListener)
If you happen to be using both, see Issue 324
Overlay.Snappable| Modifier and Type | Field and Description |
|---|---|
protected Bitmap |
mCompassFrameBitmap |
protected float |
mCompassFrameCenterX |
protected float |
mCompassFrameCenterY |
protected Bitmap |
mCompassRoseBitmap |
protected float |
mCompassRoseCenterX |
protected float |
mCompassRoseCenterY |
static int |
MENU_COMPASS |
protected long |
mLastRender |
protected MapView |
mMapView |
IOrientationProvider |
mOrientationProvider |
protected float |
mScale |
mBounds, SHADOW_X_SKEW, SHADOW_Y_SCALEDEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET| Constructor and Description |
|---|
CompassOverlay(Context context,
IOrientationProvider orientationProvider,
MapView mapView) |
CompassOverlay(Context context,
MapView mapView) |
| Modifier and Type | Method and Description |
|---|---|
void |
disableCompass()
Disable orientation updates.
|
void |
draw(Canvas c,
Projection pProjection) |
protected void |
drawCompass(Canvas canvas,
float bearing,
Rect screenRect) |
boolean |
enableCompass()
Enable receiving orientation updates from the provided IOrientationProvider and show a
compass on the map.
|
boolean |
enableCompass(IOrientationProvider orientationProvider) |
float |
getAzimuthOffset() |
float |
getOrientation() |
IOrientationProvider |
getOrientationProvider() |
boolean |
isCompassEnabled()
If enabled, the map is receiving orientation updates and drawing your location on the map.
|
boolean |
isCompassInCenter() |
boolean |
isOptionsMenuEnabled()
Can be used to signal to external callers that this Overlay should not be used for providing
option menu items.
|
boolean |
isPointerMode() |
boolean |
onCreateOptionsMenu(Menu pMenu,
int pMenuIdOffset,
MapView pMapView) |
void |
onDetach(MapView mapView)
Override to perform clean up of resources before shutdown.
|
boolean |
onOptionsItemSelected(MenuItem pItem,
int pMenuIdOffset,
MapView pMapView) |
void |
onOrientationChanged(float orientation,
IOrientationProvider source) |
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
|
boolean |
onPrepareOptionsMenu(Menu pMenu,
int pMenuIdOffset,
MapView pMapView) |
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
|
void |
setAzimuthOffset(float f)
An offset added to the bearing when drawing the compass.
|
void |
setCompassCenter(float x,
float y) |
void |
setCompassInCenter(boolean b)
Put the compass in the center of the map regardless of the supplied coordinates.
|
void |
setOptionsMenuEnabled(boolean pOptionsMenuEnabled) |
void |
setOrientationProvider(IOrientationProvider orientationProvider) |
void |
setPointerMode(boolean usePointArrow)
The compass can operate in two modes.
|
draw, drawAt, getBounds, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onScroll, onShowPress, onSingleTapConfirmed, onSingleTapUp, onTouchEvent, onTrackballEvent, setEnabledprotected MapView mMapView
public IOrientationProvider mOrientationProvider
protected Bitmap mCompassFrameBitmap
protected Bitmap mCompassRoseBitmap
protected final float mCompassFrameCenterX
protected final float mCompassFrameCenterY
protected final float mCompassRoseCenterX
protected final float mCompassRoseCenterY
protected long mLastRender
public static final int MENU_COMPASS
protected final float mScale
public CompassOverlay(Context context, IOrientationProvider orientationProvider, MapView mapView)
public void onPause()
Overlaypublic void onResume()
Overlaypublic void onDetach(MapView mapView)
Overlaypublic void setCompassCenter(float x,
float y)
public void setCompassInCenter(boolean b)
public boolean isCompassInCenter()
public void setAzimuthOffset(float f)
public float getAzimuthOffset()
public IOrientationProvider getOrientationProvider()
public void setOrientationProvider(IOrientationProvider orientationProvider) throws RuntimeException
RuntimeExceptionpublic void draw(Canvas c, Projection pProjection)
public void setOptionsMenuEnabled(boolean pOptionsMenuEnabled)
setOptionsMenuEnabled in interface IOverlayMenuProviderpublic boolean isOptionsMenuEnabled()
IOverlayMenuProviderisOptionsMenuEnabled in interface IOverlayMenuProviderpublic boolean onCreateOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)
onCreateOptionsMenu in interface IOverlayMenuProviderpublic boolean onPrepareOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)
onPrepareOptionsMenu in interface IOverlayMenuProviderpublic boolean onOptionsItemSelected(MenuItem pItem, int pMenuIdOffset, MapView pMapView)
onOptionsItemSelected in interface IOverlayMenuProviderpublic void onOrientationChanged(float orientation,
IOrientationProvider source)
onOrientationChanged in interface IOrientationConsumerorientation - this is magnetic north, not true northpublic boolean enableCompass(IOrientationProvider orientationProvider)
public boolean enableCompass()
public void disableCompass()
public boolean isCompassEnabled()
public float getOrientation()
public void setPointerMode(boolean usePointArrow)
usePointArrow - if true the pointer arrow is used, otherwise a compass rose is usedpublic boolean isPointerMode()