Skip to content Skip to sidebar Skip to footer

Disable Onmarkerclicklistener Completely In Maps Api V2

I want to disable clicking/tapping on map markers. I know you can disable default behavior by setting up an empty map.setOnMarkerClickListener and return true; However, this still

Solution 1:

Just override the onclick event:

map.setOnMarkerClickListener(newOnMarkerClickListener() {
    publicbooleanonMarkerClick(Marker arg0) {
        returntrue;
    }
});

Solution 2:

i have two suggestions:

if i understood right, you want to offer the functionality to place a marker on the map, right?! If you cannot remove the setOnMarkerClickListener, did you tried to draw at the map and "convert" your drawing to a Marker in the end. (get 'LatLng' from drawing and create a Marker).

actually the second suggestion isn't really a good one (depending if you can zoom/move your map). I had a similar task and we used an transparent overlay over the map, which handled all user input and delegates it. but we didn`t had the functionality of zoom and move, which would be pain in the ass...

Solution 3:

Solution 4:

classMyInfoWindowAdapterimplementsGoogleMap.InfoWindowAdapter
{
     @OverridepublicViewgetInfoContents(Marker mar)
     {
         returnnull;
     }
     @OverridepublicViewgetInfoWindow(Marker mar)
     {
         returnnull;
     }
}

gmap.setInfoWindowAdapter(new MyInfoWindowAdapter);

Try this code above. This will set your infowindow to null.

Solution 5:

Apply OnMarkerClickListenerto your map. Implement onMarkerClick()method and returnfalse

googleMap.setOnMarkerClickListener(newOnMarkerClickListener() {
    publicbooleanonMarkerClick(Marker marker) {
        returntrue;
    }
});

Post a Comment for "Disable Onmarkerclicklistener Completely In Maps Api V2"