Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps current location marker and accuracy radius overlay

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.

like image 976
Juliano Nunes Silva Oliveira Avatar asked Jan 19 '13 19:01

Juliano Nunes Silva Oliveira


People also ask

Can you add a radius in Google My Maps?

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.


2 Answers

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/

like image 50
Juliano Nunes Silva Oliveira Avatar answered Oct 13 '22 12:10

Juliano Nunes Silva Oliveira


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);
        }
    }
}
like image 21
Oscar Calderon Avatar answered Oct 13 '22 13:10

Oscar Calderon