0

I add a marker to the map using the code below, but after doing so I am unable to receive marker click/touch events.

If I just add the marker and don't animate to the marker's location, it seems impossible to click on the marker because of finger accuracy. Every now and then if I tap a lot really fast, I can get a click on it.

But if I do the second step below and animate to the marker's location, I can click on the marker with 100% accuracy, at least once anyway. But what happens is GoogleMap intercepts the touch and I don't get a touch event. Instead, GoogleMap displays two navigation buttons in the lower right corner of the map.

I've attached a screen shot to highlight where I've placed a marker and the navigation buttons that pop up in the lower-right when I touch that marker.

So my question is kinda two-fold. First is can I turn off those navigation buttons and receive that touch event myself?

And secondly, why do I have to animate the map camera to the specified location in order to receive any touch input?

Lastly, is there something I can set so that "fat finger" accuracy is turned on for touching markers? I'd think that unnecessary but maybe it's an issue here?

Also, I do have a Marker click listener. It's just not a direct listener because I have to manage clusters as well.

mClusterManager = new ClusterManager<>(this, mainMap);
mainMap.setOnMarkerClickListener(mClusterManager);
mClusterManager.setOnClusterItemClickListener(this);
mClusterManager.setOnClusterClickListener(this);

OnClusterItemClickListener() never gets called.

Thanks.

// Add marker - this alone doesn't make it clickable
Marker tempCursor = mainMap.addMarker(new MarkerOptions().position(newLatLng)
    .icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_pin_shadow)));

// Animate to new location - after this you can touch/click it
CameraUpdate up = CameraUpdateFactory.newLatLng(newLatLng);
mainMap.animateCamera(up);

enter image description here

Bungles
  • 1,969
  • 2
  • 25
  • 54
  • The navigation buttons can be switched off by setting the following: map.uiSettings.isMapToolbarEnabled = false. Regarding the other question, it is not clear, whether you have set an onMarkerClickListener at all. – user2808624 Mar 15 '21 at 21:41
  • Added notes on that, thanks. – Bungles Mar 15 '21 at 23:54
  • Did you also register the cluster manager as OnCameraIdleListener according to the documentation of ClusterManager? I think if you follow that documentation thoroughly, everything works as expected. – user2808624 Mar 16 '21 at 07:00
  • No, I have my own onCameraIdleListener because I need to trigger UI changes once the camera stops. – Bungles Mar 16 '21 at 17:04
  • Then you should pass into your own listener a ref to the ClusterManager and call in your onCameraIdle function also the ClusterManagers onCameraIdle function. – user2808624 Mar 16 '21 at 21:46
  • Hmm. ClusterManager doesn't appear to have an onCameraIdle function that I can call. – Bungles Mar 19 '21 at 22:55
  • But calling ClusterManageer.cluster() seemed to do the trick. Thanks! – Bungles Mar 19 '21 at 23:02
  • https://github.com/googlemaps/android-maps-utils/blob/master/library/src/main/java/com/google/maps/android/clustering/ClusterManager.java definitely has an onCameraIdle method. – user2808624 Mar 20 '21 at 09:06
  • Interesting, as it doesn't recognize the method name in the IDE. This is what worked for me. https://stackoverflow.com/questions/38906000/clustermanager-setoncameraidlelistener – Bungles Mar 21 '21 at 17:47

0 Answers0