
public class CompassOverlay extends Overlay implements IOverlayMenuProvider, IOrientationConsumer
MapView.addOnFirstLayoutListener(org.osmdroid.views.MapView.OnFirstLayoutListener)
If you happen to be using both, see Issue 324Overlay.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 MapView |
mMapView |
IOrientationProvider |
mOrientationProvider |
protected float |
mScale |
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,
MapView mapView,
boolean shadow)
Draw the overlay over the map.
|
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 |
getOrientation() |
IOrientationProvider |
getOrientationProvider() |
boolean |
isCompassEnabled()
If enabled, the map is receiving orientation updates and drawing your location on the map.
|
boolean |
isOptionsMenuEnabled()
Can be used to signal to external callers that this Overlay should not be used for providing
option menu items.
|
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) |
boolean |
onPrepareOptionsMenu(Menu pMenu,
int pMenuIdOffset,
MapView pMapView) |
void |
setCompassCenter(float x,
float y) |
void |
setOptionsMenuEnabled(boolean pOptionsMenuEnabled) |
void |
setOrientationProvider(IOrientationProvider orientationProvider) |
drawAt, 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
public static final int MENU_COMPASS
protected final float mScale
public CompassOverlay(Context context,
MapView mapView)
public CompassOverlay(Context context,
IOrientationProvider orientationProvider,
MapView mapView)
public void onDetach(MapView mapView)
Overlaypublic void setCompassCenter(float x,
float y)
public IOrientationProvider getOrientationProvider()
public void setOrientationProvider(IOrientationProvider orientationProvider) throws RuntimeException
RuntimeExceptionprotected void drawCompass(Canvas canvas,
float bearing,
Rect screenRect)
public void draw(Canvas c,
MapView mapView,
boolean shadow)
Overlaypublic 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()