how to show the current location as arrow in Google Maps Android API V2?
Asked Answered
I

3

11

I am using Google Maps Android API V2. When I use Googlemap setMyLocationEnabled(true), the current location appears as a blue dot. How can I show the current location as a flashing arrow that can indicate the current heading?

Intersperse answered 2/1, 2013 at 9:32 Comment(0)
T
6

Move!

The location will be indicated on the map by a small blue dot if the device is stationary, or as a chevron if the device is moving.

From the Google Maps v2 documentation

Threequarter answered 27/9, 2013 at 7:43 Comment(1)
Short & sweet answer..!!Evonneevonymus
L
0

Getting the blue arrow like what we see in Google's Google Maps app by default or through the API on Android is not possible according to this post. I conclude that, we may be on our own for that particular feature. Just my 2 cents.

Lenhard answered 2/5, 2014 at 2:47 Comment(0)
T
-1

(Sorry, I'm too late to answer. Hope you fixed the problem by this time.)

You can customize the way Markers should appear in some simple steps. Following are the code parts needed to achieve this.

//You need a GoogleMap object to deal with the map functionality.
private GoogleMap map;
...
//Find Your Map view from layout
map = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
//This method will do the rest needed
showMarker(userLatitude, userLongitude)
...
...
// Pass the desired latitude and longitude to this method
public void showMarker(Double lat, Double lon) {
    map.clear();
    // Create a LatLng object with the given Latitude and Longitude
    LatLng markerLoc = new LatLng(lat, lon);

    //Add marker to map
    map.addMarker(new MarkerOptions()
            .position(markerLoc)                                                                        // at the location you needed
            .title("Desired Title")                                                                     // with a title you needed
            .snippet("Any summary if needed")                                                           // and also give some summary of available
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.your_flashing_arrow_anim_drawable))); // and give your animation drawable as icon
}

// To work these functionalities, you may require the following imports
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

And finally the layout should contain an entry like this as MAP

<fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1" />

Hope this will solve some others issues too... :)

Thralldom answered 27/9, 2013 at 7:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.