From 0fd450eb8c0d742ea4d8fe4d280e80758bc77b71 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 10:42:55 +0200 Subject: [PATCH 1/8] [android] #5438 - apply rotation to with preRotate instead of postRotate --- .../com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 49141d3389b..87c7760e962 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -267,9 +267,9 @@ protected void onDraw(Canvas canvas) { // map camera matrix on our matrix camera.getMatrix(matrix); - // + // apply rotation if (myBearingTrackingMode != MyBearingTracking.NONE && directionAnimator != null) { - matrix.postRotate((Float) directionAnimator.getAnimatedValue()); + matrix.preRotate((Float) directionAnimator.getAnimatedValue()); } // put matrix at location of MyLocationView From 2695be7fab966455f0b44b7e4364e14485a633dc Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 11:04:53 +0200 Subject: [PATCH 2/8] [android] #5438 - don't disable rotation gestures when bearing tracking is being enabled. --- .../main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java index 30492bc4212..e23ed15400d 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/TrackingSettings.java @@ -215,7 +215,7 @@ private void validateGesturesForLocationTrackingMode() { private void validateGesturesForBearingTrackingMode() { int myBearingTrackingMode = getMyBearingTrackingMode(); if (!dismissBearingTrackingOnGesture) { - if (myBearingTrackingMode == MyBearingTracking.NONE) { + if (myBearingTrackingMode == MyBearingTracking.NONE || myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) { uiSettings.setRotateGesturesEnabled(true); } else { uiSettings.setRotateGesturesEnabled(false); From 0fc5e90e08cddeccb50ec577b494dcba33988871 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 11:12:44 +0200 Subject: [PATCH 3/8] [android] #5438 - remove unused params --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapView.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 8fe9568eaa6..c927ce2dde9 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -1350,10 +1350,6 @@ protected void onSizeChanged(int width, int height, int oldw, int oldh) { private class SurfaceTextureListener implements TextureView.SurfaceTextureListener { private Surface mSurface; - private View mViewHolder; - - private static final int VIEW_MARKERS_POOL_SIZE = 20; - // Called when the native surface texture has been created // Must do all EGL/GL ES initialization here From fbe367d3dd63866c4c25a974a5dbe9cbedfb9459 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 11:13:36 +0200 Subject: [PATCH 4/8] [android] #5438 - remove duplicate direction/bearing integration in MapView --- .../com/mapbox/mapboxsdk/maps/MapView.java | 61 +++++++------------ 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index c927ce2dde9..9c328ad971a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -629,40 +629,6 @@ void setTilt(Double pitch) { // Direction // - double getDirection() { - if (mDestroyed) { - return 0; - } - - double direction = -mNativeMapView.getBearing(); - - while (direction > 360) { - direction -= 360; - } - while (direction < 0) { - direction += 360; - } - - return direction; - } - - void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction) { - if (mDestroyed) { - return; - } - setDirection(direction, false); - } - - void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction, boolean animated) { - if (mDestroyed) { - return; - } - long duration = animated ? MapboxConstants.ANIMATION_DURATION : 0; - mNativeMapView.cancelTransitions(); - // Out of range directions are normalised in setBearing - mNativeMapView.setBearing(-direction, duration); - } - void resetNorth() { if (mDestroyed) { return; @@ -1392,12 +1358,12 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { return; } - mCompassView.update(getDirection()); + mCompassView.update(getBearing()); mMyLocationView.update(); try { mMapboxMap.getMarkerViewManager().update(); - }catch (NullPointerException e){ + } catch (NullPointerException e) { } for (InfoWindow infoWindow : mMapboxMap.getInfoWindows()) { @@ -1426,7 +1392,24 @@ CameraPosition invalidateCameraPosition() { if (mDestroyed) { return 0; } - return mNativeMapView.getBearing(); + + double bearing = -mNativeMapView.getBearing(); + + while (bearing > 360) { + bearing -= 360; + } + while (bearing < 0) { + bearing += 360; + } + + return bearing; + } + + void setBearing(double bearing, float centerX, float centerY) { + if (mDestroyed) { + return; + } + mNativeMapView.setBearing(bearing, centerX, centerY); } void setBearing(float bearing) { @@ -1940,10 +1923,10 @@ public boolean onRotate(RotateGestureDetector detector) { // Rotate the map if (mFocalPoint != null) { // User provided focal point - mNativeMapView.setBearing(bearing, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); + setBearing(bearing, mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); } else { // around gesture - mNativeMapView.setBearing(bearing, + setBearing(bearing, detector.getFocusX() / mScreenDensity, detector.getFocusY() / mScreenDensity); } From 2f153cd39d99bcef0535c21b43e37f69fecb1bd4 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 11:14:27 +0200 Subject: [PATCH 5/8] [android] #5438 - update test utils to handle change from direction to bearing --- .../java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java index d41c6925094..8b8cd720960 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/maps/MapboxMapUtils.java @@ -21,8 +21,8 @@ public static MapboxMap getMapboxMap(MapView mapView) { * @param mapView * @param direction */ - public static void setDirection(MapView mapView, double direction) { - mapView.setDirection(direction); + public static void setDirection(MapView mapView, float direction) { + mapView.setBearing(direction); } } From 534dc74320fe30cd3414973cf55bb34163270cb8 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 11:34:47 +0200 Subject: [PATCH 6/8] [android] #5438 - integrate mbgl camera direction into MyLocationView --- .../com/mapbox/mapboxsdk/maps/MapView.java | 12 ++++++++++-- .../mapboxsdk/maps/widgets/MyLocationView.java | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 9c328ad971a..3fde241324a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -1178,9 +1178,10 @@ void jumpTo(double bearing, LatLng center, double pitch, double zoom) { } mNativeMapView.cancelTransitions(); mNativeMapView.jumpTo(bearing, center, pitch, zoom); + mMyLocationView.updateCameraPosition(pitch, bearing); } - void easeTo(double bearing, LatLng center, long duration, double pitch, double zoom, boolean easingInterpolator, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { + void easeTo(final double bearing, LatLng center, long duration, final double pitch, double zoom, boolean easingInterpolator, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { if (mDestroyed) { return; } @@ -1194,6 +1195,8 @@ public void onMapChanged(@MapChange int change) { if (change == REGION_DID_CHANGE_ANIMATED) { cancelableCallback.onFinish(); + mMyLocationView.updateCameraPosition(pitch, bearing); + // Clean up after self removeOnMapChangedListener(this); } @@ -1204,7 +1207,7 @@ public void onMapChanged(@MapChange int change) { mNativeMapView.easeTo(bearing, center, duration, pitch, zoom, easingInterpolator); } - void flyTo(double bearing, LatLng center, long duration, double pitch, double zoom, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { + void flyTo(final double bearing, LatLng center, long duration, final double pitch, double zoom, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { if (mDestroyed) { return; } @@ -1218,6 +1221,8 @@ public void onMapChanged(@MapChange int change) { if (change == REGION_DID_CHANGE_ANIMATED) { cancelableCallback.onFinish(); + mMyLocationView.updateCameraPosition(pitch, bearing); + // Clean up after self removeOnMapChangedListener(this); } @@ -1410,6 +1415,7 @@ void setBearing(double bearing, float centerX, float centerY) { return; } mNativeMapView.setBearing(bearing, centerX, centerY); + mMyLocationView.setBearing(bearing); } void setBearing(float bearing) { @@ -1417,6 +1423,7 @@ void setBearing(float bearing) { return; } mNativeMapView.setBearing(bearing); + mMyLocationView.setBearing(bearing); } void setBearing(float bearing, long duration) { @@ -1424,6 +1431,7 @@ void setBearing(float bearing, long duration) { return; } mNativeMapView.setBearing(bearing, duration); + mMyLocationView.setBearing(bearing); } // diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 87c7760e962..64f9bbbcf85 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -1,6 +1,5 @@ package com.mapbox.mapboxsdk.maps.widgets; -import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Camera; @@ -93,6 +92,8 @@ public void onAnimationUpdate(ValueAnimator animation) { private Matrix matrix; private Camera camera; private PointF screenLocation; + + private float direction; private float tilt; @MyLocationTracking.Mode @@ -262,7 +263,7 @@ protected void onDraw(Canvas canvas) { // apply tilt to camera camera.save(); - camera.rotate(tilt, 0, 0); + camera.rotate(tilt, 0, direction); // map camera matrix on our matrix camera.getMatrix(matrix); @@ -303,6 +304,15 @@ public void setTilt(@FloatRange(from = 0, to = 60.0f) double tilt) { this.tilt = (float) tilt; } + public void setBearing(double bearing) { + this.direction = (float) bearing; + } + + public void updateCameraPosition(@FloatRange(from = 0, to = 60.0f) double tilt, double bearing) { + this.tilt = (float) tilt; + this.direction = (float) bearing; + } + void updateOnNextFrame() { mapboxMap.invalidate(); } @@ -350,8 +360,8 @@ protected Parcelable onSaveInstanceState() { } @Override - public void onRestoreInstanceState(Parcelable state){ - if (state instanceof Bundle){ + public void onRestoreInstanceState(Parcelable state) { + if (state instanceof Bundle) { Bundle bundle = (Bundle) state; tilt = bundle.getFloat("tilt"); state = bundle.getParcelable("superState"); From d384d0e9c84825fe78e7517f321ed0c7755f9992 Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 14:11:28 +0200 Subject: [PATCH 7/8] [android] #5438 - Remove old update method and replace it with an invalidation --- .../src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index b0df57fe1d1..669b8906384 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -1629,7 +1629,7 @@ void setProjection(Projection projection) { * Triggers an invalidation of the map view. */ public void invalidate() { - mMapView.update(); + mMapView.invalidate(); } /** From 684a01b030de58a44d5a384f4f74df886736026a Mon Sep 17 00:00:00 2001 From: Tobrun Van Nuland Date: Fri, 24 Jun 2016 14:15:55 +0200 Subject: [PATCH 8/8] [android] #5438 - limit amount of JNI calls for MyLocationView --- .../com/mapbox/mapboxsdk/maps/MapView.java | 33 ++++++++++--------- .../maps/widgets/MyLocationView.java | 30 ++++++++++------- 2 files changed, 36 insertions(+), 27 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java index 3fde241324a..688453743a7 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java @@ -635,6 +635,7 @@ void resetNorth() { } mNativeMapView.cancelTransitions(); mNativeMapView.resetNorth(); + mMyLocationView.setBearing(0); } // @@ -720,7 +721,7 @@ private void zoom(boolean zoomIn, float x, float y) { } // work around to invalidate camera position - postDelayed(new ZoomInvalidator(mMapboxMap), MapboxConstants.ANIMATION_DURATION); + postDelayed(new ZoomInvalidator(mMapboxMap, mMyLocationView), MapboxConstants.ANIMATION_DURATION); } // @@ -1178,7 +1179,7 @@ void jumpTo(double bearing, LatLng center, double pitch, double zoom) { } mNativeMapView.cancelTransitions(); mNativeMapView.jumpTo(bearing, center, pitch, zoom); - mMyLocationView.updateCameraPosition(pitch, bearing); + mMyLocationView.setCameraPositionAttributes(pitch, bearing); } void easeTo(final double bearing, LatLng center, long duration, final double pitch, double zoom, boolean easingInterpolator, @Nullable final MapboxMap.CancelableCallback cancelableCallback) { @@ -1195,7 +1196,7 @@ public void onMapChanged(@MapChange int change) { if (change == REGION_DID_CHANGE_ANIMATED) { cancelableCallback.onFinish(); - mMyLocationView.updateCameraPosition(pitch, bearing); + mMyLocationView.setCameraPositionAttributes(pitch, bearing); // Clean up after self removeOnMapChangedListener(this); @@ -1221,7 +1222,7 @@ public void onMapChanged(@MapChange int change) { if (change == REGION_DID_CHANGE_ANIMATED) { cancelableCallback.onFinish(); - mMyLocationView.updateCameraPosition(pitch, bearing); + mMyLocationView.setCameraPositionAttributes(pitch, bearing); // Clean up after self removeOnMapChangedListener(this); @@ -1363,7 +1364,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { return; } - mCompassView.update(getBearing()); + mCompassView.update(mMapboxMap.getCameraPosition().bearing); mMyLocationView.update(); try { @@ -1377,15 +1378,6 @@ public void onSurfaceTextureUpdated(SurfaceTexture surface) { } } - // Used by UserLocationView - void update() { - if (mDestroyed) { - return; - } - - mNativeMapView.update(); - } - CameraPosition invalidateCameraPosition() { if (mDestroyed) { return new CameraPosition.Builder().build(); @@ -1813,6 +1805,10 @@ public void onScaleEnd(ScaleGestureDetector detector) { mBeginTime = 0; mScaleFactor = 1.0f; mZoomStarted = false; + + if (mMyLocationView.isEnabled()) { + mMyLocationView.invalidateZoom(); + } } // Called each time a finger moves @@ -1850,7 +1846,7 @@ public boolean onScale(ScaleGestureDetector detector) { // Scale the map if (mFocalPoint != null) { - // arround user provided focal point + // around user provided focal point mNativeMapView.scaleBy(detector.getScaleFactor(), mFocalPoint.x / mScreenDensity, mFocalPoint.y / mScreenDensity); } else if (mQuickZoom) { // around center map @@ -2713,15 +2709,20 @@ public void onItemClick(AdapterView parent, View view, int position, long id) private static class ZoomInvalidator implements Runnable { private MapboxMap mapboxMap; + private MyLocationView myLocationView; - public ZoomInvalidator(MapboxMap mapboxMap) { + public ZoomInvalidator(MapboxMap mapboxMap, MyLocationView myLocationView) { this.mapboxMap = mapboxMap; + this.myLocationView = myLocationView; } @Override public void run() { // invalidate camera position mapboxMap.getCameraPosition(); + if(myLocationView.isEnabled()) { + myLocationView.invalidateZoom(); + } } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java index 64f9bbbcf85..1f4b2ddbfb1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java @@ -1,5 +1,6 @@ package com.mapbox.mapboxsdk.maps.widgets; +import android.animation.AnimatorListenerAdapter; import android.animation.ValueAnimator; import android.content.Context; import android.graphics.Camera; @@ -55,6 +56,8 @@ public class MyLocationView extends View { private LatLng interpolatedLocation; private LatLng previousLocation; private long locationUpdateTimestamp; + private float metersPerPixelAtLatitude; + private static final long MAX_ANIMATION_TIME = 5000; private float gpsDirection; private float previousDirection; @@ -252,9 +255,7 @@ protected void onDraw(Canvas canvas) { } final PointF pointF = screenLocation; - - float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); - float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2; + float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixelAtLatitude / 2; float maxRadius = getWidth() / 2; accuracyPixels = accuracyPixels <= maxRadius ? accuracyPixels : maxRadius; @@ -308,13 +309,17 @@ public void setBearing(double bearing) { this.direction = (float) bearing; } - public void updateCameraPosition(@FloatRange(from = 0, to = 60.0f) double tilt, double bearing) { + public void setCameraPositionAttributes(@FloatRange(from = 0, to = 60.0f) double tilt, double bearing) { this.tilt = (float) tilt; this.direction = (float) bearing; + invalidateZoom(); } - void updateOnNextFrame() { - mapboxMap.invalidate(); + public void invalidateZoom() { + if (location != null) { + metersPerPixelAtLatitude = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude()); + invalidate(); + } } public void onPause() { @@ -461,7 +466,7 @@ private void setCompass(float bearing) { previousDirection = newDir; directionAnimator = ValueAnimator.ofFloat(oldDir, newDir); - directionAnimator.setDuration(375); + directionAnimator.setDuration(575); directionAnimator.addUpdateListener(invalidateSelfOnUpdateListener); directionAnimator.start(); } @@ -516,7 +521,7 @@ private class CompassListener implements SensorEventListener { private float[] mI = new float[16]; // Controls the sensor updateLatLng rate in milliseconds - private static final int UPDATE_RATE_MS = 500; + private static final int UPDATE_RATE_MS = 1000; // Compass data private long mCompassUpdateNextTimestamp = 0; @@ -579,7 +584,7 @@ public void onAccuracyChanged(Sensor sensor, int accuracy) { } } - private class MarkerCoordinateAnimatorListener implements ValueAnimator.AnimatorUpdateListener { + private class MarkerCoordinateAnimatorListener extends AnimatorListenerAdapter implements ValueAnimator.AnimatorUpdateListener { private MyLocationBehavior behavior; private double fromLat; @@ -601,7 +606,7 @@ public void onAnimationUpdate(ValueAnimator animation) { double latitude = fromLat + (toLat - fromLat) * frac; double longitude = fromLng + (toLng - fromLng) * frac; behavior.updateLatLng(latitude, longitude); - updateOnNextFrame(); + update(); } } @@ -742,7 +747,10 @@ void updateLatLng(@NonNull final Location location) { } locationChangeAnimator = ValueAnimator.ofFloat(0.0f, 1.0f); - locationChangeAnimator.setDuration((long) (locationUpdateDuration * 1.2)); + + + long duration = (long) (locationUpdateDuration * 1.5); + locationChangeAnimator.setDuration(duration > MAX_ANIMATION_TIME ? MAX_ANIMATION_TIME : duration); locationChangeAnimator.addUpdateListener(new MarkerCoordinateAnimatorListener(this, previousLocation, interpolatedLocation ));