stephen1706 stephen1706 - 1 year ago 137
Android Question

Mapbox Android determine zoom level that contain all markers

Is there a way to determine a zoom level so that all of my markers can fit in the zoom level? i am using mapbox 0.4.0

I think the answer is similar to this, but I can't find the android version


Answer Source

okay I've figure it out. I need to create a bounding box containing all the markers

final BoundingBox zoomLevel = findZoomLevel(hotelLocation,poiLocations);

private BoundingBox findZoomLevel(LatLng hotelLocation, LatLng[] poiLocations) {
        double bottomPadding = 0.002;
        double topPadding = 0.005; 
        BoundingBox box = new BoundingBox(findTopMost(hotelLocation,poiLocations).getLatitude() + topPadding,
                findBottomMost(hotelLocation,poiLocations).getLatitude() - bottomPadding,

        return box;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download