diff options
author | Antonio Zugaldia <antonio@mapbox.com> | 2015-12-03 15:45:50 -0500 |
---|---|---|
committer | Brad Leege <bleege@gmail.com> | 2015-12-03 17:02:29 -0600 |
commit | 022d27864daff9217c3130115e648fa3434edb7d (patch) | |
tree | 12d9d524fae4001f4a2e0549f42b35db4d88791e | |
parent | c6a658087e103882b3bc16782151ec7eb4df1135 (diff) | |
download | qtlocation-mapboxgl-022d27864daff9217c3130115e648fa3434edb7d.tar.gz |
[android] #2805 - scale and clamp values for pitch
-rw-r--r-- | android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java index 6d7c666db6..5fc6c1196d 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java @@ -164,6 +164,14 @@ public final class MapView extends FrameLayout { */ public static final double MAXIMUM_ZOOM_LEVEL = 18.0; + /** + * The currently supported maximum and minimum tilt values. + * + * @see MapView#setTilt(double) + */ + private static final double MINIMUM_TILT = 0; + private static final double MAXIMUM_TILT = 60; + // // Instance members // @@ -2890,15 +2898,15 @@ public final class MapView extends FrameLayout { return false; } - // If rotate is large enough ignore a tap - // Also is zoom already started, don't rotate + // If tilt is large enough ignore a tap + // Also if zoom already started, don't tilt mTotalDelta += detector.getShovePixelsDelta(); if (!mZoomStarted && ((mTotalDelta > 10.0f) || (mTotalDelta < -10.0f))) { mStarted = true; } // Ignore short touches in case it is a tap - // Also ignore small rotate + // Also ignore small tilt long time = detector.getEventTime(); long interval = time - mBeginTime; if (!mStarted && (interval <= ViewConfiguration.getTapTimeout())) { @@ -2912,9 +2920,10 @@ public final class MapView extends FrameLayout { // Cancel any animation mNativeMapView.cancelTransitions(); - // Get rotate value + // Get tilt value (scale and clamp) double pitch = getTilt(); - pitch += detector.getShovePixelsDelta(); + pitch += 0.1 * detector.getShovePixelsDelta(); + pitch = Math.max(MINIMUM_TILT, Math.min(MAXIMUM_TILT, pitch)); // Tilt the map setTilt(pitch, null); |