[android] - move calculating a bounding box zoom level to projection. (#8133)
This commit is contained in:
@@ -259,7 +259,7 @@ public final class CameraUpdateFactory {
|
||||
float scaleX = (uiSettings.getWidth() - padding.left - padding.right) / width;
|
||||
float scaleY = (uiSettings.getHeight() - padding.top - padding.bottom) / height;
|
||||
minScale = scaleX < scaleY ? scaleX : scaleY;
|
||||
zoom = calculateZoom(mapboxMap, minScale);
|
||||
zoom = projection.calculateZoom(minScale);
|
||||
zoom = MathUtils.clamp(zoom, mapboxMap.getMinZoomLevel(), mapboxMap.getMaxZoomLevel());
|
||||
}
|
||||
|
||||
@@ -277,16 +277,6 @@ public final class CameraUpdateFactory {
|
||||
.bearing(0)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a zoom level based on minimum scale and current scale from MapView
|
||||
*
|
||||
* @param minScale The minimum scale to calculate the zoom level.
|
||||
* @return zoom level that fits the MapView.
|
||||
*/
|
||||
public double calculateZoom(MapboxMap mapboxMap, float minScale) {
|
||||
return Math.log(mapboxMap.getCameraPosition().zoom * minScale) / Math.log(2);
|
||||
}
|
||||
}
|
||||
|
||||
static final class CameraMoveUpdate implements CameraUpdate {
|
||||
|
||||
@@ -117,4 +117,14 @@ public class Projection {
|
||||
float getWidth() {
|
||||
return nativeMapView.getWidth();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates a zoom level based on minimum scale and current scale from MapView
|
||||
*
|
||||
* @param minScale The minimum scale to calculate the zoom level.
|
||||
* @return zoom level that fits the MapView.
|
||||
*/
|
||||
public double calculateZoom(float minScale) {
|
||||
return Math.log(nativeMapView.getScale() * minScale) / Math.log(2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user