From 08b5c1771ef1465bfd60155835411990c8e0c9b5 Mon Sep 17 00:00:00 2001 From: Brad Leege Date: Thu, 10 Dec 2015 17:25:54 -0800 Subject: [PATCH] [android] #3244 - Cleaning up getter and setter bearing methods --- .../com/mapbox/mapboxsdk/views/MapView.java | 31 +++++++++++++------ .../mapboxsdk/views/UserLocationView.java | 5 +-- 2 files changed, 25 insertions(+), 11 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 f71040dd17d..8391fc47ac4 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 @@ -77,7 +77,6 @@ import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngZoom; import com.mapbox.mapboxsdk.utils.ApiAccess; - import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.nio.ByteBuffer; @@ -1448,6 +1447,7 @@ public final CameraPosition getCameraPosition () { */ public final void animateCamera (CameraUpdate update) { + // Order Matters! Otherwise Core GL will stomp on things setCenterCoordinate(update.getTarget()); setZoomLevel(update.getZoom()); setTilt(new Double(update.getTilt()), 0L); @@ -2474,20 +2474,33 @@ void update() { } } - double getBearing() { + /** + * Get Bearing in degrees + * @return Bearing in degrees + */ + public double getBearing() { return mNativeMapView.getBearing(); } - // Used by UserLocationView - void setBearing(float bearing) { - mNativeMapView.setBearing(bearing, 100); - } - -/* + /** + * Set Bearing in degrees + * @param bearing Bearing in degrees + */ public void setBearing(float bearing) { mNativeMapView.setBearing(bearing); } -*/ + + /** + * Sets Bearing in degrees + * + * NOTE: Used by UserLocationView + * + * @param bearing Bearing in degrees + * @param duration Length of time to rotate + */ + public void setBearing(float bearing, long duration) { + mNativeMapView.setBearing(bearing, duration); + } // // View events diff --git a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java index 2869eaafbdf..07d3f85e6f6 100644 --- a/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java +++ b/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java @@ -87,6 +87,7 @@ final class UserLocationView extends View implements LocationListener { // Compass data private MyBearingListener mBearingChangeListener; + private static final long BEARING_DURATION = 100; public UserLocationView(Context context) { super(context); @@ -553,7 +554,7 @@ previousCoordinate, new LatLng(location) mShowDirection = true; mGpsMarkerDirection = 0; if (location.hasBearing()) { - mMapView.setBearing(location.getBearing()); + mMapView.setBearing(location.getBearing(), BEARING_DURATION); } } @@ -600,7 +601,7 @@ private void setCompass(float bearing) { mShowDirection = true; mGpsMarkerDirection = 0; mCompassMarkerDirection = 0; - mMapView.setBearing(bearing); + mMapView.setBearing(bearing, BEARING_DURATION); } } }