Android cluster and marker clicks

You can create a new MarkerManager that you pass into the ClusterManager constructor. Then make a new Marker collection using MarkerManager#newCollection and add your normal Markers to the map using the MarkerManager.Collection#addMarker method.

Then, instead of calling mMap.setOnMarkerClickListener(mClusterManager), call mMap.setOnMarkerClickListener(mMarkerManager), and it will handle forwarding your Marker click events to the proper listeners. You’ll also need to set up your onMarkerClick listener for normal Markers with the MarkerManager.Collection#setOnMarkerClickListener(GoogleMap.OnMarkerClickListener markerClickListener) function.

I recommend looking over the source of the MarkerManager and ClusterManager classes to get a better idea of how the classes interact.

Leave a Comment