diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index e18b4ab4d61..98cbeab468d 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -8,7 +8,7 @@ dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
- compile 'com.squareup.okhttp3:okhttp:3.3.0'
+ compile 'com.squareup.okhttp3:okhttp:3.4.1'
compile 'com.mapzen.android:lost:1.1.1'
// Mapbox Android Services
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
index 2459f6e79a5..b902a1b3bc7 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
@@ -136,33 +136,38 @@ InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offset
boolean outOfBoundsLeft = false;
boolean outOfBoundsRight = false;
- // if out of bounds right
- if (rightSideInfowWindow > mapRight) {
- outOfBoundsRight = true;
- x -= rightSideInfowWindow - mapRight;
- tipViewMarginLeft += rightSideInfowWindow - mapRight + tipViewOffset;
- rightSideInfowWindow = x + view.getMeasuredWidth();
- }
+ // only optimise margins if view is inside current viewport
+ if (mCoordinates.x >= 0 && mCoordinates.x <= mapView.getWidth()
+ && mCoordinates.y >= 0 && mCoordinates.y <= mapView.getHeight()) {
+
+ // if out of bounds right
+ if (rightSideInfowWindow > mapRight) {
+ outOfBoundsRight = true;
+ x -= rightSideInfowWindow - mapRight;
+ tipViewMarginLeft += rightSideInfowWindow - mapRight + tipViewOffset;
+ rightSideInfowWindow = x + view.getMeasuredWidth();
+ }
- // fit screen left
- if (leftSideInfoWindow < mapLeft) {
- outOfBoundsLeft = true;
- x += mapLeft - leftSideInfoWindow;
- tipViewMarginLeft -= mapLeft - leftSideInfoWindow + tipViewOffset;
- leftSideInfoWindow = x;
- }
+ // fit screen left
+ if (leftSideInfoWindow < mapLeft) {
+ outOfBoundsLeft = true;
+ x += mapLeft - leftSideInfoWindow;
+ tipViewMarginLeft -= mapLeft - leftSideInfoWindow + tipViewOffset;
+ leftSideInfoWindow = x;
+ }
- // Add margin right
- if (outOfBoundsRight && mapRight - rightSideInfowWindow < marginHorizontal) {
- x -= marginHorizontal - (mapRight - rightSideInfowWindow);
- tipViewMarginLeft += marginHorizontal - (mapRight - rightSideInfowWindow) - tipViewOffset;
- leftSideInfoWindow = x;
- }
+ // Add margin right
+ if (outOfBoundsRight && mapRight - rightSideInfowWindow < marginHorizontal) {
+ x -= marginHorizontal - (mapRight - rightSideInfowWindow);
+ tipViewMarginLeft += marginHorizontal - (mapRight - rightSideInfowWindow) - tipViewOffset;
+ leftSideInfoWindow = x;
+ }
- // Add margin left
- if (outOfBoundsLeft && leftSideInfoWindow - mapLeft < marginHorizontal) {
- x += marginHorizontal - (leftSideInfoWindow - mapLeft);
- tipViewMarginLeft -= (marginHorizontal - (leftSideInfoWindow - mapLeft)) - tipViewOffset;
+ // Add margin left
+ if (outOfBoundsLeft && leftSideInfoWindow - mapLeft < marginHorizontal) {
+ x += marginHorizontal - (leftSideInfoWindow - mapLeft);
+ tipViewMarginLeft -= (marginHorizontal - (leftSideInfoWindow - mapLeft)) - tipViewOffset;
+ }
}
// Adjust tipView
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java
index 175fd57da4f..72037c2565e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerView.java
@@ -265,17 +265,9 @@ public void setRotation(float rotation) {
newRotation += 360;
}
- // calculate new direction
- float diff = newRotation - this.rotation;
- if (diff > 180.0f) {
- diff -= 360.0f;
- } else if (diff < -180.0f) {
- diff += 360.f;
- }
-
this.rotation = newRotation;
if (markerViewManager != null) {
- markerViewManager.animateRotationBy(this, diff);
+ markerViewManager.animateRotationBy(this, newRotation);
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
index 36f43abb114..8d29bf2d2eb 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerViewManager.java
@@ -74,12 +74,20 @@ public void animateRotation(@NonNull MarkerView marker, float rotation) {
* Animate a MarkerView with a given rotation.
*
* @param marker the MarkerView to rotate by
- * @param rotation the rotation by value
+ * @param rotation the rotation by value, limited to 0 - 360 degrees
*/
public void animateRotationBy(@NonNull MarkerView marker, float rotation) {
View convertView = markerViewMap.get(marker);
if (convertView != null) {
- AnimatorUtils.rotateBy(convertView, rotation);
+ convertView.animate().cancel();
+ // calculate new direction
+ float diff = rotation - convertView.getRotation();
+ if (diff > 180.0f) {
+ diff -= 360.0f;
+ } else if (diff < -180.0f) {
+ diff += 360.f;
+ }
+ AnimatorUtils.rotateBy(convertView, diff);
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
index 6c5e76dc456..fabf66af385 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/camera/CameraPosition.java
@@ -9,6 +9,8 @@
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.utils.MathUtils;
+import static com.mapbox.mapboxsdk.utils.MathUtils.convertNativeBearing;
+
/**
* Resembles the position, angle, zoom and tilt of the user's viewpoint.
*/
@@ -202,7 +204,7 @@ public Builder(double[] nativeCameraValues) {
super();
if (nativeCameraValues != null && nativeCameraValues.length == 5) {
target(new LatLng(nativeCameraValues[0], nativeCameraValues[1]));
- bearing(nativeCameraValues[2]);
+ bearing(convertNativeBearing(nativeCameraValues[2]));
tilt(nativeCameraValues[3]);
zoom((float) nativeCameraValues[4]);
}
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 fc916024b10..278c811c033 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
@@ -89,6 +89,8 @@
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
+import static com.mapbox.mapboxsdk.utils.MathUtils.convertNativeBearing;
+
/**
*
* A {@code MapView} provides an embeddable map interface.
@@ -151,6 +153,7 @@ public class MapView extends FrameLayout {
private boolean styleWasSet = false;
private List onMapReadyCallbackList;
+ private MapboxMap.CancelableCallback cameraCancelableCallback;
private SnapshotRequest snapshotRequest;
private boolean onStartCalled;
@@ -708,16 +711,7 @@ void setTilt(Double pitch) {
return 0;
}
- double direction = -nativeMapView.getBearing();
-
- while (direction > 360) {
- direction -= 360;
- }
- while (direction < 0) {
- direction += 360;
- }
-
- return direction;
+ return convertNativeBearing(nativeMapView.getBearing());
}
void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = MapboxConstants.MAXIMUM_DIRECTION) double direction) {
@@ -732,7 +726,7 @@ void setDirection(@FloatRange(from = MapboxConstants.MINIMUM_DIRECTION, to = Map
return;
}
long duration = animated ? MapboxConstants.ANIMATION_DURATION : 0;
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Out of range directions are normalised in setBearing
nativeMapView.setBearing(-direction, duration);
}
@@ -742,7 +736,7 @@ void resetNorth() {
return;
}
myLocationView.setBearing(0);
- nativeMapView.cancelTransitions();
+ cancelTransitions();
nativeMapView.resetNorth();
}
@@ -812,7 +806,7 @@ private void zoom(boolean zoomIn) {
private void zoom(boolean zoomIn, float x, float y) {
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
if (zoomIn) {
nativeMapView.scaleBy(2.0, x / screenDensity, y / screenDensity, MapboxConstants.ANIMATION_DURATION);
@@ -1066,11 +1060,19 @@ public void invalidateContentPadding() {
// Mapbox Core GL Camera
//
+ private void cancelTransitions(){
+ if (cameraCancelableCallback != null) {
+ cameraCancelableCallback.onCancel();
+ cameraCancelableCallback = null;
+ }
+ nativeMapView.cancelTransitions();
+ }
+
void jumpTo(double bearing, LatLng center, double pitch, double zoom) {
if (destroyed) {
return;
}
- nativeMapView.cancelTransitions();
+ cancelTransitions();
nativeMapView.jumpTo(bearing, center, pitch, zoom);
}
@@ -1078,16 +1080,17 @@ void easeTo(double bearing, LatLng center, long duration, double pitch, double z
if (destroyed) {
return;
}
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Register callbacks early enough
if (cancelableCallback != null) {
+ cameraCancelableCallback = cancelableCallback;
addOnMapChangedListener(new OnMapChangedListener() {
@Override
public void onMapChanged(@MapChange int change) {
- if (change == REGION_DID_CHANGE_ANIMATED) {
- cancelableCallback.onFinish();
-
+ if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) {
+ cameraCancelableCallback.onFinish();
+ cameraCancelableCallback = null;
// Clean up after self
removeOnMapChangedListener(this);
}
@@ -1102,16 +1105,17 @@ void flyTo(double bearing, LatLng center, long duration, double pitch, double zo
if (destroyed) {
return;
}
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Register callbacks early enough
if (cancelableCallback != null) {
+ cameraCancelableCallback = cancelableCallback;
addOnMapChangedListener(new OnMapChangedListener() {
@Override
public void onMapChanged(@MapChange int change) {
- if (change == REGION_DID_CHANGE_ANIMATED) {
+ if (change == REGION_DID_CHANGE_ANIMATED && cameraCancelableCallback != null) {
cancelableCallback.onFinish();
-
+ cameraCancelableCallback = null;
// Clean up after self
removeOnMapChangedListener(this);
}
@@ -1545,7 +1549,7 @@ public boolean onSingleTapUp(MotionEvent motionEvent) {
return false;
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
return true;
}
@@ -1647,7 +1651,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
double duration = speed / (deceleration * ease);
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
nativeMapView.moveBy(velocityX * duration / 2.0 / screenDensity, velocityY * duration / 2.0 / screenDensity, (long) (duration * 1000.0f));
@@ -1679,7 +1683,7 @@ public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float d
// reset tracking if needed
resetTrackingModesIfRequired(true, false);
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Scroll the map
nativeMapView.moveBy(-distanceX / screenDensity, -distanceY / screenDensity);
@@ -1750,7 +1754,7 @@ public boolean onScale(ScaleGestureDetector detector) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Gesture is a quickzoom if there aren't two fingers
quickZoom = !twoTap;
@@ -1831,7 +1835,7 @@ public boolean onRotate(RotateGestureDetector detector) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// rotation constitutes translation of anything except the center of
// rotation, so cancel both location and bearing tracking if required
@@ -1907,7 +1911,7 @@ public boolean onShove(ShoveGestureDetector detector) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Get tilt value (scale and clamp)
double pitch = getTilt();
@@ -1974,7 +1978,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Move left
nativeMapView.moveBy(scrollDist / screenDensity, 0.0 / screenDensity);
@@ -1986,7 +1990,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Move right
nativeMapView.moveBy(-scrollDist / screenDensity, 0.0 / screenDensity);
@@ -1998,7 +2002,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Move up
nativeMapView.moveBy(0.0 / screenDensity, scrollDist / screenDensity);
@@ -2010,7 +2014,7 @@ public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Move down
nativeMapView.moveBy(0.0 / screenDensity, -scrollDist / screenDensity);
@@ -2090,7 +2094,7 @@ public boolean onTrackballEvent(MotionEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Scroll the map
nativeMapView.moveBy(-10.0 * event.getX() / screenDensity, -10.0 * event.getY() / screenDensity);
@@ -2186,7 +2190,7 @@ public boolean onGenericMotionEvent(MotionEvent event) {
}
// Cancel any animation
- nativeMapView.cancelTransitions();
+ cancelTransitions();
// Get the vertical scroll amount, one click = 1
float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
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 36860b1ceff..300804c468c 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
@@ -541,8 +541,6 @@ private class CompassListener implements SensorEventListener {
float[] matrix = new float[9];
float[] orientation = new float[3];
- private int currentDegree = 0;
-
// Compass data
private long compassUpdateNextTimestamp = 0;
@@ -575,22 +573,22 @@ public void onSensorChanged(SensorEvent event) {
SensorManager.getOrientation(matrix, orientation);
float magneticHeading = (float) Math.toDegrees(SensorManager.getOrientation(matrix, orientation)[0]);
- currentDegree = (int) (magneticHeading);
-
- // Change the user location view orientation to reflect the device orientation
- setCompass(currentDegree);
-
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
- rotateCamera();
+ // Change the user location view orientation to reflect the device orientation
+ rotateCamera(magneticHeading);
+ setCompass(0);
+ } else {
+ // Change compass direction
+ setCompass(magneticHeading);
}
compassUpdateNextTimestamp = currentTime + COMPASS_UPDATE_RATE_MS;
}
}
- private void rotateCamera() {
+ private void rotateCamera(float rotation) {
CameraPosition.Builder builder = new CameraPosition.Builder();
- builder.bearing(currentDegree);
+ builder.bearing(rotation);
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), COMPASS_UPDATE_RATE_MS, false /*linear interpolator*/, false /*do not disable tracking*/, null);
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java
index a92999c0d51..2c1a1b8e649 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/MathUtils.java
@@ -43,4 +43,22 @@ public static double wrap(double value, double min, double max) {
return secondMod + min;
}
+
+ /**
+ * Convert bearing from core to match Android SDK value.
+ *
+ * @param nativeBearing bearing value coming from core
+ * @return bearing in degrees starting from 0 rotating clockwise
+ */
+ public static double convertNativeBearing(double nativeBearing) {
+ double direction = -nativeBearing;
+
+ while (direction > 360) {
+ direction -= 360;
+ }
+ while (direction < 0) {
+ direction += 360;
+ }
+ return direction;
+ }
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
index 81e7097eb3b..3a7d8b4a5c3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/MarkerViewActivity.java
@@ -172,6 +172,24 @@ public boolean onMarkerClick(@NonNull Marker marker, @NonNull View view, @NonNul
.icon(IconFactory.getInstance(mapView.getContext())
.fromResource(R.drawable.ic_arsenal))
);
+
+ // allow more open infowindows at the same time
+ mapboxMap.setAllowConcurrentMultipleOpenInfoWindows(true);
+
+ // add offscreen markers
+ Marker markerRightOffScreen = mapboxMap.addMarker(new MarkerOptions()
+ .setPosition(new LatLng(38.892846, -76.909399))
+ .title("InfoWindow")
+ .snippet("Offscreen, to the right of the Map."));
+
+ Marker markerRightBottomOffScreen = mapboxMap.addMarker(new MarkerOptions()
+ .setPosition(new LatLng(38.791645, -77.039006))
+ .title("InfoWindow")
+ .snippet("Offscreen, to the bottom of the Map"));
+
+ // open infowindow offscreen markers
+ mapboxMap.selectMarker(markerRightOffScreen);
+ mapboxMap.selectMarker(markerRightBottomOffScreen);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
index 68f3f802776..1f2f7346c42 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/camera/CameraPositionActivity.java
@@ -87,7 +87,17 @@ public void onClick(DialogInterface dialog, int which) {
.tilt(tilt)
.build();
- mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000);
+ mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 5000, new MapboxMap.CancelableCallback() {
+ @Override
+ public void onCancel() {
+ Log.v(MapboxConstants.TAG, "OnCancel called");
+ }
+
+ @Override
+ public void onFinish() {
+ Log.v(MapboxConstants.TAG, "OnFinish called");
+ }
+ });
Log.v(MapboxConstants.TAG, cameraPosition.toString());
}
});
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
index 6cef1898bdb..eaeae78abb9 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/com/mapbox/mapboxsdk/annotations/MarkerViewTest.java
@@ -146,7 +146,6 @@ public void testRotationBelowMin() {
public void testRotationUpdatePositive() {
float startRotation = 45;
float endRotation = 180;
- float animationValue = 135;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -156,14 +155,13 @@ public void testRotationUpdatePositive() {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test
public void testRotationUpdateNegative() {
float startRotation = 10;
float endRotation = 270;
- float animationValue = -100;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -173,14 +171,13 @@ public void testRotationUpdateNegative() {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test
public void testRotationUpdateMax() {
float startRotation = 359;
float endRotation = 0;
- float animationValue = 1;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -190,14 +187,13 @@ public void testRotationUpdateMax() {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, 0);
}
@Test
public void testRotationUpdateMin() {
float startRotation = 0;
float endRotation = 359;
- float animationValue = -1;
// allow calls to our mock
when(mapboxMap.getMarkerViewManager()).thenReturn(markerViewManager);
@@ -207,7 +203,7 @@ public void testRotationUpdateMin() {
marker.setMapboxMap(mapboxMap);
marker.setRotation(endRotation);
- verify(markerViewManager, times(1)).animateRotationBy(marker, animationValue);
+ verify(markerViewManager, times(1)).animateRotationBy(marker, endRotation);
}
@Test
diff --git a/platform/android/src/jni.cpp b/platform/android/src/jni.cpp
index 01d3a01227b..1168fb9b891 100755
--- a/platform/android/src/jni.cpp
+++ b/platform/android/src/jni.cpp
@@ -498,7 +498,7 @@ jdoubleArray nativeGetCameraValues(JNIEnv *env, jni::jobject* obj, jlong nativeM
jdouble buf[5];
buf[0] = latLng.latitude;
buf[1] = latLng.longitude;
- buf[2] = -(nativeMapView->getMap().getBearing()-360);
+ buf[2] = -nativeMapView->getMap().getBearing();
buf[3] = nativeMapView->getMap().getPitch();
buf[4] = nativeMapView->getMap().getZoom();
env->SetDoubleArrayRegion(output, start, leng, buf);
@@ -1008,7 +1008,7 @@ void nativeJumpTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl
mbgl::CameraOptions options;
if (angle != -1) {
- options.angle = angle * M_PI / 180;
+ options.angle = (-angle * M_PI) / 180;
}
options.center = mbgl::LatLng(latitude, longitude);
options.padding = nativeMapView->getInsets();
@@ -1028,7 +1028,7 @@ void nativeEaseTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdoubl
mbgl::CameraOptions cameraOptions;
if (angle != -1) {
- cameraOptions.angle = angle * M_PI / 180;
+ cameraOptions.angle = (-angle * M_PI) / 180;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = nativeMapView->getInsets();
@@ -1061,7 +1061,7 @@ void nativeFlyTo(JNIEnv *env, jni::jobject* obj, jlong nativeMapViewPtr, jdouble
mbgl::CameraOptions cameraOptions;
if (angle != -1) {
- cameraOptions.angle = angle * M_PI / 180 ;
+ cameraOptions.angle = (-angle * M_PI) / 180 ;
}
cameraOptions.center = mbgl::LatLng(latitude, longitude);
cameraOptions.padding = nativeMapView->getInsets();