mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

Reinstate some sort of fitToMarkers

Open afathman opened this issue 10 years ago • 1 comments

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 avatar May 13 '16 18:05 afathman

@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!

tobrun avatar May 17 '16 11:05 tobrun