Skip to content Skip to sidebar Skip to footer

How Do I Disable Click On A Map Marker In Android?

I've written my custom location listener which checks the user's location in every 10 minutes and updates a marker on the map which denotes the user's location. The problem is that

Solution 1:

Try this code.

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            return true;
        }
    });

Returning true will also prevent info window from being opened.

For using this with a ClusterManager:

mMap.setOnMarkerClickListener(new GoogleMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            if (marker == user_marker) {
               return true;
            }
            return clusterManager.onMarkerClick(marker);
        }
    });

Post a Comment for "How Do I Disable Click On A Map Marker In Android?"