Reputation: 3962
I am trying to set min zoom level to be 15 and user cannot zoom out of that level but he can zoom into 20 .
So throughout the app the user can use zoom enabled(true) but cannot go out of zoom level 15.Should I disable zoom afte 15 ? but that would even disable zoom in .
I dont know how to manage onl one condition in this case .How do I do it.I really appreciate any help.
Thanks in Advance
public OnCameraChangeListener getCameraChangeListener()
{
return new OnCameraChangeListener()
{
@Override
public void onCameraChange(CameraPosition position)
{
Log.d("Zoom", "Zoom: " + position.zoom);
if(previousZoomLevel != position.zoom)
{
isZooming = true;
if(zoomscale==15){
googleMap.getUiSettings().setZoomGesturesEnabled(false);
googleMap.getUiSettings().setZoomControlsEnabled(false);
}
}
previousZoomLevel = position.zoom;
}
};
}
Upvotes: 1
Views: 1732
Reputation: 37
mMap.setMinZoomPreference(float yourDesiredLevel)
;Upvotes: 2
Reputation: 22232
As of current version (3.2.65) there is no API for setting min/max zoom level.
Hopefully there will be in the future, as this is already requested on gmaps-api-issues.
Anyway there is a way to handle it nicely in your own code: in onCameraChange
if zoom is smaller than 15, call GoogleMap.animateCamera
back to zoom 15. It will not stop the user from zooming out to see the whole world, but it will start zooming in after user finishes doing what they feel like doing. It will look similar to this: http://youtube.com/watch?v=-nCZ37HdheY (not only zoom, but also position is "corrected").
Upvotes: 2