[android] - move calculating a bounding box zoom level to projection. (#8133)

This commit is contained in:
Tobrun
2017-02-23 14:08:38 +01:00
committed by GitHub
parent 272d874267
commit 79ab42f791
2 changed files with 11 additions and 11 deletions

View File

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

View File

@@ -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);
}
}