How can I display a blinking ellipsis and a circle demonstrating user's current location and the accuracy (blue overlay) on Google Maps Android API v2?
To be more specifically, how can I have an animated drawable like the one Google uses? And how can I display a circle as a blue overlay (25% alpha or something like)?
Thanks.
Google Maps does not support the radius functionality, which means that you can't determine the radius around a given location. But you can measure the distance between two or more points. As a quick reminder, the radius of a circle is the distance from its edge to its center.
Actually, the solution is simpler than I thought.
When using Google Maps Android API v2, the GoogleMap object has a method called setMyLocation. If you set it to true, the my-location layout of the Maps API will be activated and it will display this blue ellipsis or an arrow indicating the bearing.
If you need to automatically move the camera to the user's location when the activity is created, you need to follow this article: http://discgolfsoftware.wordpress.com/2012/12/06/google-maps-android-api-v2-mylocation-locationsource-and-event-handling/
setup your map with setMyLocationEnabled(true) for example:
private void setUpMapIfNeeded() {
// Do a null check to confirm that we have not already instantiated the map.
if (mMap == null) {
// Try to obtain the map from the SupportMapFragment.
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
// Check if we were successful in obtaining the map.
if (mMap != null) {
mMap.setMyLocationEnabled(true);
mMap.setOnMyLocationButtonClickListener(this);
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With