
public class MyLocationNewOverlay extends Overlay implements IMyLocationConsumer, IOverlayMenuProvider, Overlay.Snappable
Overlay.Snappable| Modifier and Type | Field and Description |
|---|---|
protected boolean |
enableAutoStop
if true, when the user pans the map, follow my location will automatically disable
if false, when the user pans the map, the map will continue to follow current location
|
protected Paint |
mCirclePaint |
protected Bitmap |
mDirectionArrowBitmap |
protected float |
mDirectionArrowCenterX |
protected float |
mDirectionArrowCenterY |
protected boolean |
mDrawAccuracyEnabled |
static int |
MENU_MY_LOCATION |
protected boolean |
mIsFollowing |
protected MapView |
mMapView |
IMyLocationProvider |
mMyLocationProvider |
protected Paint |
mPaint |
protected Bitmap |
mPersonBitmap |
protected PointF |
mPersonHotspot
Coordinates the feet of the person are located scaled for display density.
|
protected float |
mScale |
mBounds, SHADOW_X_SKEW, SHADOW_Y_SCALEDEFAULT_ZOOMLEVEL_MINIMAP_DIFFERENCE, NOT_SET| Constructor and Description |
|---|
MyLocationNewOverlay(IMyLocationProvider myLocationProvider,
MapView mapView) |
MyLocationNewOverlay(MapView mapView) |
| Modifier and Type | Method and Description |
|---|---|
void |
disableFollowLocation()
Disables "follow" functionality.
|
void |
disableMyLocation()
Disable location updates
|
void |
draw(Canvas c,
Projection pProjection) |
protected void |
drawMyLocation(Canvas canvas,
Projection pj,
Location lastFix) |
void |
enableFollowLocation()
Enables "follow" functionality.
|
boolean |
enableMyLocation()
Enable receiving location updates from the provided IMyLocationProvider and show your
location on the maps.
|
boolean |
enableMyLocation(IMyLocationProvider myLocationProvider) |
boolean |
getEnableAutoStop() |
Location |
getLastFix() |
GeoPoint |
getMyLocation()
Return a GeoPoint of the last known location, or null if not known.
|
IMyLocationProvider |
getMyLocationProvider() |
boolean |
isDrawAccuracyEnabled()
If enabled, an accuracy circle will be drawn around your current position.
|
boolean |
isFollowLocationEnabled()
If enabled, the map will center on your current location and automatically scroll as you
move.
|
boolean |
isMyLocationEnabled()
If enabled, the map is receiving location 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.
|
void |
onLocationChanged(Location location,
IMyLocationProvider source)
Call when a provider has a new location to consume.
|
boolean |
onOptionsItemSelected(MenuItem pItem,
int pMenuIdOffset,
MapView pMapView) |
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
|
boolean |
onSnapToItem(int x,
int y,
Point snapPoint,
IMapView mapView)
Checks to see if the given x and y are close enough to an item resulting in snapping the
current action (e.g.
|
boolean |
onTouchEvent(MotionEvent event,
MapView mapView)
You can prevent all(!) other Touch-related events from happening!
By default does nothing ( return false). |
boolean |
runOnFirstFix(Runnable runnable)
Queues a runnable to be executed as soon as we have a location fix.
|
void |
setDirectionArrow(Bitmap personBitmap,
Bitmap directionArrowBitmap)
fix for https://github.com/osmdroid/osmdroid/issues/249
|
void |
setDrawAccuracyEnabled(boolean drawAccuracyEnabled)
If enabled, an accuracy circle will be drawn around your current position.
|
void |
setEnableAutoStop(boolean value) |
protected void |
setLocation(Location location) |
protected void |
setMyLocationProvider(IMyLocationProvider myLocationProvider) |
void |
setOptionsMenuEnabled(boolean pOptionsMenuEnabled) |
void |
setPersonHotspot(float x,
float y) |
void |
setPersonIcon(Bitmap icon)
enabls you to change the my location 'person' icon at runtime.
|
protected void |
stopLocationProvider() |
draw, drawAt, getBounds, getSafeMenuId, getSafeMenuIdSequence, isEnabled, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onScroll, onShowPress, onSingleTapConfirmed, onSingleTapUp, onTrackballEvent, setEnabledprotected Paint mPaint
protected Paint mCirclePaint
protected final float mScale
protected Bitmap mPersonBitmap
protected Bitmap mDirectionArrowBitmap
protected MapView mMapView
public IMyLocationProvider mMyLocationProvider
protected boolean enableAutoStop
protected boolean mIsFollowing
protected boolean mDrawAccuracyEnabled
protected final PointF mPersonHotspot
protected float mDirectionArrowCenterX
protected float mDirectionArrowCenterY
public static final int MENU_MY_LOCATION
public MyLocationNewOverlay(MapView mapView)
public MyLocationNewOverlay(IMyLocationProvider myLocationProvider, MapView mapView)
public void setDirectionArrow(Bitmap personBitmap, Bitmap directionArrowBitmap)
personBitmap - directionArrowBitmap - public void onResume()
Overlaypublic void onPause()
Overlaypublic void onDetach(MapView mapView)
Overlaypublic void setDrawAccuracyEnabled(boolean drawAccuracyEnabled)
drawAccuracyEnabled - whether the accuracy circle will be enabledpublic boolean isDrawAccuracyEnabled()
public IMyLocationProvider getMyLocationProvider()
protected void setMyLocationProvider(IMyLocationProvider myLocationProvider)
public void setPersonHotspot(float x,
float y)
protected void drawMyLocation(Canvas canvas, Projection pj, Location lastFix)
public void draw(Canvas c, Projection pProjection)
public boolean onSnapToItem(int x,
int y,
Point snapPoint,
IMapView mapView)
Overlay.SnappableonSnapToItem in interface Overlay.Snappablex - The x in screen coordinates.y - The y in screen coordinates.snapPoint - To be filled with the the interesting point (in screen coordinates) that is
closest to the given x and y. Can be untouched if not snapping.mapView - The MapView that is requesting the snap. Use MapView.getProjection()
to convert between on-screen pixels and latitude/longitude pairs.public void setEnableAutoStop(boolean value)
public boolean getEnableAutoStop()
public boolean onTouchEvent(MotionEvent event, MapView mapView)
Overlayreturn 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.onTouchEvent in class 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 GeoPoint getMyLocation()
public Location getLastFix()
public void enableFollowLocation()
public void disableFollowLocation()
public boolean isFollowLocationEnabled()
public void onLocationChanged(Location location, IMyLocationProvider source)
IMyLocationConsumeronLocationChanged in interface IMyLocationConsumerprotected void setLocation(Location location)
public boolean enableMyLocation(IMyLocationProvider myLocationProvider)
public boolean enableMyLocation()
public void disableMyLocation()
protected void stopLocationProvider()
public boolean isMyLocationEnabled()
public boolean runOnFirstFix(Runnable runnable)
public void setPersonIcon(Bitmap icon)
setPersonHotspot(float, float)icon -