Setting max zoom level in google maps android api v2

user2223820 picture user2223820 · Mar 29, 2013 · Viewed 45.3k times · Source

I'm currently working on developing apps by using Google maps android API v2. My code is as follows. Suppose map has several markers and zoom up to show all markers in display.

LatLngBuilder.Builder builder = LatLngBounds.builder();
for(Marker m : markers){
    builder.include(m.getPosition());
}
LatLngBounds bounds = builder.build();
map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10);

This code is working fine but I want to stop animating when the zoom level reached to 17.0f; It seems map API does not have such method to control zoom level. Does anybody know any idea to solve this problem?

Answer

Dmitry Serov picture Dmitry Serov · Aug 2, 2016

A recent update to the Google Maps API introduces the functions you require:

GoogleMap.setMaxZoomPreference()

GoogleMap.setMinZoomPreference()

It still does not prevent the animation from playing, though.