Android Make Disappear or remove the blue dot on the map v2

Sergio76 picture Sergio76 · Feb 23, 2015 · Viewed 8.8k times · Source

I'm trying to replace the blue dot on the map of my app. My intention is that instead of the usual blue dot, show an icon shaped plane. I achieve this and it works perfectly as follows:

//...
GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
            @Override
            public void onMyLocationChange(Location location) {
                LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());

 try{
                    myPositionMarker.remove();
                } catch (Exception e){
                 //..
                }

                myPositionMarker = mMap.addMarker(new MarkerOptions()
                        .flat(true)
                        .icon(BitmapDescriptorFactory
                                .fromResource(R.drawable.plane))
                        .anchor(0.5f, 0.5f)
                        .position(
                                new LatLng(location.getLatitude(), location
                                        .getLongitude())));
//...
}

As I said, this works fine, but now I see my icon and the blue dot:

enter image description here

I have tried many ways to do it, but can not find any that work. There are many examples of removing the button "My Location" but I do not want to delete it.

I want to remove the blue dot.

enter image description here

I appreciate any help. Thanks in advance and greetings

*UPDATE:

Responding to the comment written by @tyczj i'm removing my location button as follows:

mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMyLocationButtonEnabled(false);

Thus, my location button is not visible, but the blue dot is visible. Change the two boolean to false and then no longer works. No blue dot, but neither location update. I'm a little confused. What am I doing wrong?

Thanks

Answer

Marian Paździoch picture Marian Paździoch · Feb 25, 2015

If you want to have "google's go-to-my-location-button" you have to have "google's blue dot". If you don't want "google's blue dot" you also will not have "google's go-to-my-location-button" and thus you'll have to implement it by yourself. Just add requestLocationUpdates (GoogleApiClient client, LocationRequest request, LocationListener listener) to track user location and add your custom "go-to-my-location-button" on top of map.