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.


One more way to receive the click event for Marker is using OnClusterItemClickListener interface.

Call mClusterManager.setOnClusterItemClickListener(this); and make your class implement OnClusterItemClickListener

Then inside the onClusterItemClick method, you will get the ClusterItem which is the marker that was clicked,

@Override
public boolean onClusterItemClick(ClusterItem clusterItem) {

    Toast.makeText(getActivity(), "Latitude " + clusterItem.getPosition().latitude, Toast.LENGTH_LONG).show();

    return true;
}