summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobrun <tobrun.van.nuland@gmail.com>2017-02-27 20:22:25 +0100
committerJustin R. Miller <incanus@codesorcery.net>2017-02-27 14:22:25 -0500
commit147654a46bea6025366010574c41e99dfbd9384d (patch)
tree9e456b72cd44ea09229fc58139bd0bd3b3460640
parentc70bf6b2bf4b01e01ecf86768906ddf631f18629 (diff)
downloadqtlocation-mapboxgl-147654a46bea6025366010574c41e99dfbd9384d.tar.gz
[android] - reverse compass direction (#8130)
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
index ed6ef5199a..6d8adc1e2a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/CompassView.java
@@ -34,7 +34,7 @@ public final class CompassView extends AppCompatImageView implements Runnable, F
private static final long TIME_FADE_ANIMATION = TIME_WAIT_IDLE;
private static final long TIME_MAP_NORTH_ANIMATION = 150;
- private double direction = 0.0;
+ private float rotation = 0.0f;
private boolean fadeCompassViewFacingNorth = true;
private ViewPropertyAnimatorCompat fadeAnimator;
private PointF focalPoint;
@@ -82,8 +82,8 @@ public final class CompassView extends AppCompatImageView implements Runnable, F
}
public boolean isFacingNorth() {
- // increase range more than just 0.0
- return direction >= 359.0 || direction <= 1.0;
+ // increase range of facing north to more than only 0.0
+ return Math.abs(rotation) >= 359.0 || Math.abs(rotation) <= 1.0;
}
@Override
@@ -105,8 +105,14 @@ public final class CompassView extends AppCompatImageView implements Runnable, F
return focalPoint;
}
- public void update(final double direction) {
- this.direction = direction;
+ /**
+ * Updates the direction of the compass.
+ *
+ * @param bearing the direction value of the map
+ */
+ public void update(final double bearing) {
+ // compass needs reverse bearing #8123
+ rotation = (float) -bearing;
if (!isEnabled()) {
return;
@@ -124,7 +130,7 @@ public final class CompassView extends AppCompatImageView implements Runnable, F
setVisibility(View.VISIBLE);
}
- setRotation((float) direction);
+ setRotation(rotation);
}
public void fadeCompassViewFacingNorth(boolean compassFadeFacingNorth) {