Disable onMarkerClickListener completely in Maps API v2

后端 未结 6 1381
无人及你
无人及你 2021-02-07 08:30

I want to disable clicking/tapping on map markers. I know you can disable default behavior by setting up an empty map.setOnMarkerClickListener

相关标签:
6条回答
  • 2021-02-07 09:10

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

    googleMap.setOnMarkerClickListener(new OnMarkerClickListener() {
        public boolean onMarkerClick(Marker marker) {
            return true;
        }
    });
    
    0 讨论(0)
  • 2021-02-07 09:11

    map.setOnMarkerClickListener(null); try this

    0 讨论(0)
  • 2021-02-07 09:17

    It is not necessary to implement OnMarkerClickListner. Just try to remove this statement

    map.setOnMarkerClickListner(this)
    

    from your code and I hope it will solve your problem.

    0 讨论(0)
  • 2021-02-07 09:20
    class MyInfoWindowAdapter implements GoogleMap.InfoWindowAdapter
    {
         @Override
         public View getInfoContents(Marker mar)
         {
             return null;
         }
         @Override
         public View getInfoWindow(Marker mar)
         {
             return null;
         }
    }
    

    gmap.setInfoWindowAdapter(new MyInfoWindowAdapter);

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

    0 讨论(0)
  • 2021-02-07 09:23

    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...

    0 讨论(0)
  • 2021-02-07 09:26

    Just override the onclick event:

    map.setOnMarkerClickListener(new OnMarkerClickListener() {
        public boolean onMarkerClick(Marker arg0) {
            return true;
        }
    });
    
    0 讨论(0)
提交回复
热议问题