summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java26
1 files changed, 21 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
index 988f01dce8..45a13ed58b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/plugins/locationlayer/LocationLayerPlugin.java
@@ -114,7 +114,9 @@ public final class LocationLayerPlugin {
= new CopyOnWriteArrayList<>();
/**
- * Construct a LocationLayerPlugin
+ * Construct a LocationLayerPlugin. In order to display location,
+ * the location layer has to be activated with {@link LocationLayerPlugin#activateLocationLayerPlugin(Context)},
+ * or one of the overloads.
*
* @param mapboxMap the MapboxMap to apply the LocationLayerPlugin with
*/
@@ -156,6 +158,22 @@ public final class LocationLayerPlugin {
* <p>
* <strong>Note</strong>: This constructor will initialize and use an internal {@link LocationEngine}.
*
+ * @param context the context
+ */
+ @RequiresPermission(anyOf = {ACCESS_FINE_LOCATION, ACCESS_COARSE_LOCATION})
+ public void activateLocationLayerPlugin(@NonNull Context context, boolean useDefaultLocationEngine) {
+ if (useDefaultLocationEngine) {
+ activateLocationLayerPlugin(context, R.style.mapbox_LocationLayer);
+ } else {
+ activateLocationLayerPlugin(context, null, R.style.mapbox_LocationLayer);
+ }
+ }
+
+ /**
+ * This method will show the location icon and enable the camera tracking the location.
+ * <p>
+ * <strong>Note</strong>: This constructor will initialize and use an internal {@link LocationEngine}.
+ *
* @param context the context
* @param styleRes the LocationLayerPlugin style res
*/
@@ -312,9 +330,7 @@ public final class LocationLayerPlugin {
public void applyStyle(LocationLayerOptions options) {
this.options = options;
locationLayer.applyStyle(options);
- if (!options.enableStaleState()) {
- staleStateManager.onStop();
- }
+ staleStateManager.setEnabled(options.enableStaleState());
staleStateManager.setDelayTime(options.staleStateTimeout());
updateMapWithOptions(options);
}
@@ -740,7 +756,7 @@ public final class LocationLayerPlugin {
SensorManager sensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
compassEngine = new LocationLayerCompassEngine(windowManager, sensorManager);
compassEngine.addCompassListener(compassListener);
- staleStateManager = new StaleStateManager(onLocationStaleListener, options.staleStateTimeout());
+ staleStateManager = new StaleStateManager(onLocationStaleListener, options);
updateMapWithOptions(options);