MapView onCLick Event Listener

So, I'm trying to detect click events for MapView to trigger a method with a click.

Trying any change to the standard onClickListener or onTouch not good.

I do not want to add a β€œclick” overlay to a specific part of the map. I want the map to continue to respond to drag and drop, zoom, etc.

Any help would be appreciated.

+6
source share
2 answers

So, obviously, the solution is pretty simple. I assume it has been added to one of the latest support libraries. Now GoogleMap supports onMapClick.

 mMapView.getMap().setOnMapClickListener(new OnMapClickListener() { @Override public void onMapClick(LatLng arg0) { android.util.Log.i("onMapClick", "Horray!"); } }); 
+14
source

In the new version of Google Play services, you must call the method after the card is ready, with the onMapReady(GoogleMap map); .

  @Override public void onMapReady(GoogleMap googleMap) { googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() { @Override public void onMapClick(LatLng arg0) { android.util.Log.i("onMapClick", "Horray!"); } }); } 
+6
source

All Articles