Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable marker click event?

I am developing an simple app, where I already displayed marker title with mrkr.showInfoWindow() but I don't want user to tap again that marker. How to disable clicking event of particular marker ?

This is how I tried.

   Marker marker = gMap.addMarker(new MarkerOptions().position(new LatLng(location
                    .getLatitude(), location.getLongitude())).title("I am here").icon(BitmapDescriptorFactory.fromResource(R.drawable.mrk1)));
            marker.showInfoWindow();
//how to use marker.setClickable here or somthing here.?

How to display that infowindow()/title of my marker throughout my application ?

like image 202
Aparichith Avatar asked Apr 21 '14 12:04

Aparichith


People also ask

How to remove marker google Maps api?

To remove a marker from the map, call the setMap() method passing null as the argument. marker. setMap(null);

How to set marker in google map in javascript?

Map(document. getElementById("map"), mapOptions); // To add the marker to the map, use the 'map' property var marker = new google. maps. Marker({ position: new google.


1 Answers

You can set onMarkerClickListener in GoogleMap object

Java:

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

In Kotlin, you can simply do:

map.setOnMarkerClickListener { true }
like image 97
Wishmaster Avatar answered Oct 07 '22 12:10

Wishmaster