summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Hellwig <martin.hellwig@bosch-softtec.com>2018-01-25 17:04:53 +0100
committerTobrun <tobrun.van.nuland@gmail.com>2018-02-02 10:35:33 +0100
commit3109c008b84e8b01be01a4708aa8136b949a0a66 (patch)
tree02e9ba36d04a08f2fb96b1ad9832aa0ab90b7c31
parent295c16fa81fe46d0af0870e8f7dbf0e5e6d00b60 (diff)
downloadqtlocation-mapboxgl-3109c008b84e8b01be01a4708aa8136b949a0a66.tar.gz
Implement new bearingTrackingMode GPS_NORTH_FACING
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java7
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/widgets/MyLocationView.java23
2 files changed, 24 insertions, 6 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java
index ceac862f39..c042b00577 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MyBearingTracking.java
@@ -22,7 +22,7 @@ import java.lang.annotation.RetentionPolicy;
*/
public class MyBearingTracking {
- @IntDef( {NONE, COMPASS, GPS})
+ @IntDef( {NONE, COMPASS, GPS, GPS_NORTH_FACING})
@Retention(RetentionPolicy.SOURCE)
public @interface Mode {
}
@@ -42,4 +42,9 @@ public class MyBearingTracking {
*/
public static final int GPS = 0x00000008;
+ /**
+ * Tracking the bearing of the user based on GPS data, but camera always faces north direction
+ */
+ public static final int GPS_NORTH_FACING = 0x0000000B;
+
}
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 4f27e0ada8..1cdd91028d 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
@@ -356,7 +356,9 @@ public class MyLocationView extends View {
foregroundDrawable.draw(canvas);
}
} else if (foregroundBearingDrawable != null && foregroundBounds != null) {
- if (myBearingTrackingMode == MyBearingTracking.GPS || compassListener.isSensorAvailable()) {
+ if (myBearingTrackingMode == MyBearingTracking.GPS
+ || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING
+ || compassListener.isSensorAvailable()) {
foregroundBearingDrawable.draw(canvas);
} else {
// We are tracking MyBearingTracking.COMPASS, but sensor is not available.
@@ -383,7 +385,8 @@ public class MyLocationView extends View {
public void setBearing(double bearing) {
this.bearing = bearing;
if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
- if (myBearingTrackingMode == MyBearingTracking.GPS) {
+ if (myBearingTrackingMode == MyBearingTracking.GPS
+ || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) {
if (location != null) {
setCompass(location.getBearing() - bearing);
}
@@ -519,7 +522,8 @@ public class MyLocationView extends View {
}
private void toggleGps(boolean enableGps) {
- toggleGps(enableGps, mapboxMap != null && mapboxMap.getTrackingSettings().isCustomLocationSource());
+ toggleGps(enableGps, mapboxMap != null
+ && mapboxMap.getTrackingSettings().isCustomLocationSource());
}
/**
@@ -580,7 +584,8 @@ public class MyLocationView extends View {
this.location = location;
myLocationBehavior.updateLatLng(location);
- if (mapboxMap != null && myBearingTrackingMode == MyBearingTracking.GPS
+ if (mapboxMap != null && (myBearingTrackingMode == MyBearingTracking.GPS
+ || myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING)
&& myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
setBearing(mapboxMap.getCameraPosition().bearing);
}
@@ -616,7 +621,8 @@ public class MyLocationView extends View {
compassListener.onResume();
} else {
compassListener.onPause();
- if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
+ if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW
+ && myBearingTrackingMode == MyBearingTracking.GPS) {
// always face north
setCompass(0);
} else {
@@ -1017,6 +1023,13 @@ public class MyLocationView extends View {
setCompass(0, COMPASS_UPDATE_RATE_MS);
}
+ if (myBearingTrackingMode == MyBearingTracking.GPS_NORTH_FACING) {
+ builder.bearing(0);
+ if (location.hasBearing()) {
+ setCompass(location.getBearing(), COMPASS_UPDATE_RATE_MS);
+ }
+ }
+
// accuracy
updateAccuracy(location);