mapbox-gl-native
mapbox-gl-native copied to clipboard
Reinstate some sort of fitToMarkers
In previous versions of Mapbox, it was possible to fit to markers or zoom to a bounding box. The latest version allows you to pick a center point (which is easy enough to calculate), but no easy way of determining what the zoom would be to encapsulate the markers/points on screen. Either reinstating a zoom to bounding box or providing a zoom-until-all-are-visible function would be nice.
Platform:Android Mapbox SDK version:4.0.0
@afathman this use-case can be solved by using:
LatLngBounds bounds = new LatLngBounds.Builder()
.include(latLng1)
.include(latLng2)
.include(latLng3)
.build();
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 0));
The camera update will calculate the correct zoom level based on the point added to the bounds.
Reach out if you have any other questions!