Disable clustering at max zoom level using android-maps-utils
I've run into the same need just today. This is my solution: Since you can't set setOnCameraChangeListener twice, remove
googleMap.setOnCameraChangeListener(clusterManager);
and replace it with
googleMap.setOnCameraChangeListener(new GoogleMap.OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition cameraPosition) {
shouldCluster_zoom = cameraPosition.zoom < 9; //disables the cluster at 9 and higher zoom levels
clusterManager.onCameraChange(cameraPosition); //Replaces googleMap.setOnCameraChangeListener(clusterManager);
}
});
"shouldCluster_zoom
" obviously is a global variable, static and boolean.
Now in "shouldRenderAsCluster
" method check, according to the zoom, if markers should be clustered:
@Override
protected boolean shouldRenderAsCluster(Cluster<T> cluster) {
return super.shouldRenderAsCluster(cluster) && Your_class_name.shouldCluster_zoom;
}