Reputation: 1011
I need an explanation of how to work with CameraUpdateFactory. My app draws a route on the screen and I need to centralize this route map. Then get the bounds of the route and try to set the zoom. But when I run the huge zoom, referring to the documentation says CameraUpdateFactory of the highest zoom possible but that's not what I need.
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 6));
}
});
Upvotes: 0
Views: 620
Reputation: 1011
Adjusting google map (api v2) zoom level in android
It works!
mMap.addMarker(new MarkerOptions().position(fromPosition).title(start_address));
mMap.addMarker(new MarkerOptions().position(toPosition).title(end_address));
com.google.android.gms.maps.model.LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
boundsBuilder.include(fromPosition);
boundsBuilder.include(toPosition);
final LatLngBounds bounds = boundsBuilder.build();
mMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, 12));
}
});
Upvotes: 2