Dynamic zoom in Google Maps API v2 Android -


in google maps api v2, method animatecamera used define zoom level viewing. example,

googlemap.animatecamera(cameraupdatefactory.newlatlngzoom(new latlng(lat1, lng1), 12)); 

here, zoom level fixed 12. how make sure zoom value fixed here, allow user view source , destination points along route without manual zooming.

i know using trial , error methods , if-else conditions, values can determined. there more sophisticated way of doing this?

you can use latlngbounds this:

latlngbounds.builder builder = new latlngbounds.builder(); builder.include(startpoint); builder.include(endpoint); latlngbounds bound = builder.build(); map.animatecamera(cameraupdatefactory.newlatlngbounds(bound, 25), 1000, null); 

startpoint , endpoint latlng objects.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -