I am using Google Maps Android Marker Clustering Utility to enable clustering for my markers. In order to use this library, i need to set the map's cameraChangeListener to be object of type ClusterManager. The problem is that i want to control the minimum zoom level, so that when zoom level goes below some threshold, to set it's value back to so predefined value. But, when i set onCameraChangeListener to object of type ClusterManager i lose the possibility to control the zoom level.
Does somebody know how to control zoom level when using this library ?
Many thanks!
I will test this later, but roughly, you'll need to customize your onCameraChangeListener
a bit.
As specified in @DiscDev's answer here, register a callback method on the map as follows:
mMap.setOnCameraChangeListener(getCameraChangeListener())
.
Your getCameraChangeListener should handle the zoom the way you want it to, before calling ClusterManager:
public OnCameraChangeListener getCameraChangeListener()
{
return new OnCameraChangeListener()
{
@Override
public void onCameraChange(CameraPosition position)
{
if (position.zoom < [minimum desired position]) {
mMap.animateCamera(CameraUpdateFactory.zoomTo( [float value of desired zoom level] );
}
mClusterManager.onCameraChange(mMap.getCameraPosition());
}
}
}