diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-12-11 19:00:15 +0100 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-12-13 19:40:24 +0100 |
commit | e86d1b2ac99452819396e2e617a77b2918cd5a04 (patch) | |
tree | 4c53f9726e44ce1483735a45cacbad6d64242171 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java | |
parent | bbeec8dacb1a007ffadad391b63620b6d2575eb7 (diff) | |
download | qtlocation-mapboxgl-e86d1b2ac99452819396e2e617a77b2918cd5a04.tar.gz |
[android] immediate location animation based on map's projection
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java index 7a2415ed5d..2e95da8ad5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/Utils.java @@ -16,6 +16,7 @@ import android.support.v4.content.ContextCompat; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.maps.MapboxMap; +import com.mapbox.mapboxsdk.maps.Projection; import static com.mapbox.mapboxsdk.location.LocationComponentConstants.INSTANT_LOCATION_TRANSITION_THRESHOLD; @@ -92,13 +93,10 @@ public final class Utils { return (float) (location.getAccuracy() * (1 / metersPerPixel)); } - static boolean immediateAnimation(LatLng current, @NonNull LatLng target, double zoom) { - // TODO: calculate the value based on the projection + static boolean immediateAnimation(@NonNull Projection projection, @NonNull LatLng current, @NonNull LatLng target) { + double metersPerPixel = projection.getMetersPerPixelAtLatitude((current.getLatitude() + target.getLatitude()) / 2); double distance = current.distanceTo(target); - if (zoom > 10) { - distance *= zoom; - } - return distance > INSTANT_LOCATION_TRANSITION_THRESHOLD; + return distance / metersPerPixel > INSTANT_LOCATION_TRANSITION_THRESHOLD; } /** |