diff options
Diffstat (limited to 'platform')
2 files changed, 11 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java index bdc0938456..95f34b9b70 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapGestureDetector.java @@ -419,7 +419,7 @@ final class MapGestureDetector { return false; } - if (tiltGestureOccurred) { + if (tiltGestureOccurred || scaleGestureOccurred) { return false; } @@ -476,9 +476,14 @@ final class MapGestureDetector { @Override public void onScaleEnd(ScaleGestureDetector detector) { double velocityXY = Math.abs(velocityTracker.getYVelocity()) + Math.abs(velocityTracker.getXVelocity()); - if (velocityXY > MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING) { + if (velocityXY > MapboxConstants.VELOCITY_THRESHOLD_IGNORE_FLING / 2) { long animationTime = (long)(Math.log(velocityXY) * 66); - transform.zoom(wasZoomingIn, new PointF(detector.getFocusX(), detector.getFocusY()), animationTime); + double zoomAddition = (float) (Math.log(velocityXY) / 7.7); + if (!wasZoomingIn) { + zoomAddition = -zoomAddition; + } + scaleGestureOccurred = true; + transform.zoom(zoomAddition, new PointF(detector.getFocusX(), detector.getFocusY()), animationTime); handler.postDelayed(new Runnable() { @Override public void run() { @@ -509,7 +514,7 @@ final class MapGestureDetector { // Also ignore small scales long time = detector.getEventTime(); long interval = time - scaleBeginTime; - if (!scaleGestureOccurred && (interval <= ViewConfiguration.getTapTimeout())) { + if (!scaleGestureOccurred && (interval <= ViewConfiguration.getTapTimeout() / 3)) { return false; } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java index 026564902c..e18e7f91c6 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Transform.java @@ -221,10 +221,10 @@ final class Transform implements MapView.OnMapChangedListener { } } - void zoom(boolean zoomIn, @NonNull PointF focalPoint,long duration) { + void zoom(double zoomAddition, @NonNull PointF focalPoint,long duration) { CameraPosition cameraPosition = invalidateCameraPosition(); if (cameraPosition != null) { - int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1)); + int newZoom = (int) Math.round(cameraPosition.zoom + zoomAddition); setZoom(newZoom, focalPoint, duration); } else { // we are not transforming, notify about being idle |