diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java index e53d430b69..0d5745d4c9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Projection.java @@ -1,6 +1,7 @@ package com.mapbox.mapboxsdk.maps; import android.graphics.PointF; +import android.support.annotation.FloatRange; import android.support.annotation.NonNull; import com.mapbox.mapboxsdk.geometry.LatLng; @@ -21,6 +22,20 @@ public class Projection { } /** + * <p> + * Returns the distance spanned by one pixel at the specified latitude and current zoom level. + * </p> + * The distance between pixels decreases as the latitude approaches the poles. + * This relationship parallels the relationship between longitudinal coordinates at different latitudes. + * + * @param latitude The latitude for which to return the value. + * @return The distance measured in meters. + */ + public double getMetersPerPixelAtLatitude(@FloatRange(from = -180, to = 180) double latitude) { + return mMapView.getMetersPerPixelAtLatitude(latitude); + } + + /** * Returns the geographic location that corresponds to a screen location. * The screen location is specified in screen pixels (not display pixels) relative to the * top left of the map (not the top left of the whole screen). @@ -55,7 +70,7 @@ public class Projection { .include(bottomRight) .include(bottomLeft); - return new VisibleRegion(topLeft,topRight,bottomLeft,bottomRight,builder.build()); + return new VisibleRegion(topLeft, topRight, bottomLeft, bottomRight, builder.build()); } /** @@ -69,4 +84,14 @@ public class Projection { public PointF toScreenLocation(LatLng location) { return mMapView.toScreenLocation(location); } + + /** + * 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(mMapView.getScale() * minScale) / Math.log(2); + } } |