-
- All Implemented Interfaces:
-
org.osmdroid.views.overlay.IOverlayMenuProvider,org.osmdroid.views.overlay.Overlay.Snappable,org.osmdroid.views.overlay.mylocation.IMyLocationConsumer,org.osmdroid.views.util.constants.OverlayConstants
public class MyLocationNewOverlay extends Overlay implements IMyLocationConsumer, IOverlayMenuProvider, Overlay.Snappable
-
-
Field Summary
Fields Modifier and Type Field Description public IMyLocationProvidermMyLocationProviderprotected booleanenableAutoStoppublic final static intMENU_MY_LOCATION
-
Constructor Summary
Constructors Constructor Description MyLocationNewOverlay(MapView mapView)MyLocationNewOverlay(IMyLocationProvider myLocationProvider, MapView mapView)
-
Method Summary
Modifier and Type Method Description booleangetEnableAutoStop()voidsetEnableAutoStop(boolean value)voidsetDirectionArrow(Bitmap personBitmap, Bitmap directionArrowBitmap)fix for https://github. voidsetDirectionIcon(Bitmap pDirectionArrowBitmap)voidonResume()Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github. voidonPause()Triggered on application lifecycle changes, assuming the mapview is triggered appropriatelyrelated issue https://github.com/osmdroid/osmdroid/issues/823https://github. voidonDetach(MapView mapView)Override to perform clean up of resources before shutdown. voidsetDrawAccuracyEnabled(boolean drawAccuracyEnabled)If enabled, an accuracy circle will be drawn around your current position. booleanisDrawAccuracyEnabled()If enabled, an accuracy circle will be drawn around your current position. IMyLocationProvidergetMyLocationProvider()voidsetPersonHotspot(float x, float y)voiddraw(Canvas c, Projection pProjection)booleanonSnapToItem(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 thecurrent action (e.g. booleanonTouchEvent(MotionEvent event, MapView mapView)You can prevent all(!) other Touch-related events from happening! voidsetOptionsMenuEnabled(boolean pOptionsMenuEnabled)booleanisOptionsMenuEnabled()Can be used to signal to external callers that this Overlay should not be used for providingoption menu items. booleanonCreateOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)booleanonPrepareOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)booleanonOptionsItemSelected(MenuItem pItem, int pMenuIdOffset, MapView pMapView)GeoPointgetMyLocation()Return a GeoPoint of the last known location, or null if not known. LocationgetLastFix()voidenableFollowLocation()Enables "follow" functionality. voiddisableFollowLocation()Disables "follow" functionality. booleanisFollowLocationEnabled()If enabled, the map will center on your current location and automatically scroll as youmove. voidonLocationChanged(Location location, IMyLocationProvider source)Call when a provider has a new location to consume. booleanenableMyLocation(IMyLocationProvider myLocationProvider)booleanenableMyLocation()Enable receiving location updates from the provided IMyLocationProvider and show yourlocation on the maps. voiddisableMyLocation()Disable location updates booleanisMyLocationEnabled()If enabled, the map is receiving location updates and drawing your location on the map. booleanrunOnFirstFix(Runnable runnable)Queues a runnable to be executed as soon as we have a location fix. voidsetPersonIcon(Bitmap icon)enables you to change the my location 'person' icon at runtime. voidsetPersonAnchor(float pHorizontal, float pVertical)Anchors for the person iconExpected values between 0 and 1, 0 being top/left, . voidsetDirectionAnchor(float pHorizontal, float pVertical)Anchors for the direction iconExpected values between 0 and 1, 0 being top/left, . -
Methods inherited from class org.osmdroid.views.overlay.Overlay
draw, draw, getBounds, isEnabled, onDetach, onDoubleTap, onDoubleTapEvent, onDown, onFling, onKeyDown, onKeyUp, onLongPress, onScroll, onShowPress, onSingleTapConfirmed, onSingleTapUp, onTrackballEvent, setEnabled -
Methods inherited from class org.osmdroid.views.overlay.mylocation.IMyLocationConsumer
onLocationChanged -
Methods inherited from class org.osmdroid.views.overlay.IOverlayMenuProvider
onCreateOptionsMenu, onOptionsItemSelected, onPrepareOptionsMenu -
Methods inherited from class org.osmdroid.views.overlay.Overlay.Snappable
onSnapToItem -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
MyLocationNewOverlay
MyLocationNewOverlay(MapView mapView)
-
MyLocationNewOverlay
MyLocationNewOverlay(IMyLocationProvider myLocationProvider, MapView mapView)
-
-
Method Detail
-
getEnableAutoStop
boolean getEnableAutoStop()
-
setEnableAutoStop
void setEnableAutoStop(boolean value)
-
setDirectionArrow
@Deprecated() void setDirectionArrow(Bitmap personBitmap, Bitmap directionArrowBitmap)
fix for https://github.com/osmdroid/osmdroid/issues/249
-
setDirectionIcon
void setDirectionIcon(Bitmap pDirectionArrowBitmap)
-
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
-
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
-
onDetach
void onDetach(MapView mapView)
Override to perform clean up of resources before shutdown. By default does nothing.
-
setDrawAccuracyEnabled
void setDrawAccuracyEnabled(boolean drawAccuracyEnabled)
If enabled, an accuracy circle will be drawn around your current position.
- Parameters:
drawAccuracyEnabled- whether the accuracy circle will be enabled
-
isDrawAccuracyEnabled
boolean isDrawAccuracyEnabled()
If enabled, an accuracy circle will be drawn around your current position.
-
getMyLocationProvider
IMyLocationProvider getMyLocationProvider()
-
setPersonHotspot
@Deprecated() void setPersonHotspot(float x, float y)
-
draw
void draw(Canvas c, Projection pProjection)
-
onSnapToItem
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 thecurrent action (e.g. zoom) to the item.
- Parameters:
x- The x in screen coordinates.y- The y in screen coordinates.snapPoint- To be filled with the the interesting point (in screen coordinates) that isclosest to the given x and y.mapView- The MapView that is requesting the snap.
-
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.
-
setOptionsMenuEnabled
void setOptionsMenuEnabled(boolean pOptionsMenuEnabled)
-
isOptionsMenuEnabled
boolean isOptionsMenuEnabled()
Can be used to signal to external callers that this Overlay should not be used for providingoption menu items.
-
onCreateOptionsMenu
boolean onCreateOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)
-
onPrepareOptionsMenu
boolean onPrepareOptionsMenu(Menu pMenu, int pMenuIdOffset, MapView pMapView)
-
onOptionsItemSelected
boolean onOptionsItemSelected(MenuItem pItem, int pMenuIdOffset, MapView pMapView)
-
getMyLocation
GeoPoint getMyLocation()
Return a GeoPoint of the last known location, or null if not known.
-
getLastFix
Location getLastFix()
-
enableFollowLocation
void enableFollowLocation()
Enables "follow" functionality. The map will center on your current location andautomatically scroll as you move. Scrolling the map in the UI will disable.
-
disableFollowLocation
void disableFollowLocation()
Disables "follow" functionality.
-
isFollowLocationEnabled
boolean isFollowLocationEnabled()
If enabled, the map will center on your current location and automatically scroll as youmove. Scrolling the map in the UI will disable.
-
onLocationChanged
void onLocationChanged(Location location, IMyLocationProvider source)
Call when a provider has a new location to consume. This can be called on any thread.
-
enableMyLocation
boolean enableMyLocation(IMyLocationProvider myLocationProvider)
-
enableMyLocation
boolean enableMyLocation()
Enable receiving location updates from the provided IMyLocationProvider and show yourlocation on the maps. You will likely want to call enableMyLocation() from your Activity'sActivity.onResume() method, to enable the features of this overlay. Remember to call thecorresponding disableMyLocation() in your Activity's Activity.onPause() method to turn offupdates when in the background.
-
disableMyLocation
void disableMyLocation()
Disable location updates
-
isMyLocationEnabled
boolean isMyLocationEnabled()
If enabled, the map is receiving location updates and drawing your location on the map.
-
runOnFirstFix
boolean runOnFirstFix(Runnable runnable)
Queues a runnable to be executed as soon as we have a location fix. If we already have a fix,we'll execute the runnable immediately and return true. If not, we'll hang on to the runnableand return false; as soon as we get a location fix, we'll run it in in a new thread.
-
setPersonIcon
void setPersonIcon(Bitmap icon)
enables you to change the my location 'person' icon at runtime. note that thehotspot is not updated with this method. see setPersonAnchor
-
setPersonAnchor
void setPersonAnchor(float pHorizontal, float pVertical)
Anchors for the person iconExpected values between 0 and 1, 0 being top/left, .5 center and 1 bottom/right
-
setDirectionAnchor
void setDirectionAnchor(float pHorizontal, float pVertical)
Anchors for the direction iconExpected values between 0 and 1, 0 being top/left, .5 center and 1 bottom/right
-
-
-
-