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 b3b91205b48..057efe07b03 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 @@ -457,7 +457,7 @@ public void onMapChanged(@MapChange int change) { } else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) { mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation(); - mCompassView.update(getDirection()); + mCompassView.update(getBearing()); mMyLocationView.update(); mMapboxMap.getMarkerViewManager().update(); @@ -634,45 +634,6 @@ void setTilt(Double pitch) { mNativeMapView.setPitch(pitch, 0); } - - // - // 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; @@ -1405,7 +1366,17 @@ CameraPosition invalidateCameraPosition() { if (mDestroyed) { return 0; } - return mNativeMapView.getBearing(); + + double direction = -mNativeMapView.getBearing(); + + while (direction > 360) { + direction -= 360; + } + while (direction < 0) { + direction += 360; + } + + return direction; } void setBearing(float bearing) { @@ -1422,6 +1393,13 @@ void setBearing(float bearing, long duration) { mNativeMapView.setBearing(bearing, duration); } + void setBearing(double bearing, float focalX, float focalY) { + if (mDestroyed) { + return; + } + mNativeMapView.setBearing(bearing, focalX, focalY); + } + // // View events // @@ -1931,12 +1909,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, - detector.getFocusX() / mScreenDensity, - detector.getFocusY() / mScreenDensity); + setBearing(bearing, detector.getFocusX() / mScreenDensity, detector.getFocusY() / mScreenDensity); } return true; }