The MyLocationOverlay class is a special Overlay designed to show your current location and orientation on a MapView.
To use My Location Overlay you need to create a new instance, passing in the application Context and target Map View, and add it to the MapView's Overlay list, as shown here:
List<Overlay> overlays = mapView.getOverlays(); MyLocationOverlay myLocationOverlay =
new MyLocationOverlay(this, mapView); overlays.add(myLocationOverlay);
You can use My Location Overlay to display both your current location (represented as a flashing blue marker) and your current orientation (shown as a compass on the map display).
The following snippet shows how to enable both the compass and marker; in this instance the Map View's MapController is also passed in, allowing the Overlay to automatically scroll the map if the marker moves offscreen.
Was this article helpful?
Quick start guide to skyrocket your offline and online business success with mobile apps. If you know anything about mobile devices, you’ve probably heard that famous phrase coined by one of the mobile device’s most prolific creators proclaiming that there’s an app for pretty much everything.