diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java index afd25f13f..2c063daa8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/constants/MapboxConstants.java @@ -117,6 +117,11 @@ public class MapboxConstants { */ public static final String FRAG_ARG_MAPBOXMAPOPTIONS = "MapboxMapOptions"; + /** + * Layer Id of annotations layer + */ + public static final String LAYER_ID_ANNOTATIONS = "com.mapbox.annotations.points"; + // Save instance state keys public static final String STATE_HAS_SAVED_STATE = "mapbox_savedState"; public static final String STATE_CAMERA_POSITION = "mapbox_cameraPosition"; @@ -126,7 +131,6 @@ public class MapboxConstants { public static final String STATE_TILT_ENABLED = "mapbox_tiltEnabled"; public static final String STATE_DOUBLE_TAP_ENABLED = "mapbox_doubleTapEnabled"; public static final String STATE_DEBUG_ACTIVE = "mapbox_debugActive"; - public static final String STATE_STYLE_URL = "mapbox_styleUrl"; public static final String STATE_COMPASS_ENABLED = "mapbox_compassEnabled"; public static final String STATE_COMPASS_GRAVITY = "mapbox_compassGravity"; public static final String STATE_COMPASS_MARGIN_LEFT = "mapbox_compassMarginLeft"; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java index b2f1206d0..aa281ee31 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationComponent.java @@ -11,7 +11,6 @@ import android.support.annotation.RequiresPermission; import android.support.annotation.StyleRes; import android.support.annotation.VisibleForTesting; import android.view.WindowManager; - import com.mapbox.android.core.location.LocationEngine; import com.mapbox.android.core.location.LocationEngineCallback; import com.mapbox.android.core.location.LocationEngineProvider; @@ -123,7 +122,12 @@ public final class LocationComponent { /** * Indicates whether the component has been initialized. */ - private boolean isInitialized; + private boolean isComponentInitialized; + + /** + * Indicates whether the style has been initialized. + */ + private boolean isStyleInitialized; /** * Indicates that the component is enabled and should be displaying location if Mapbox components are available and @@ -182,7 +186,6 @@ public final class LocationComponent { this.staleStateManager = staleStateManager; this.compassEngine = compassEngine; this.internalLocationEngineProvider = internalLocationEngineProvider; - isInitialized = true; } /** @@ -835,16 +838,17 @@ public final class LocationComponent { * Internal use. */ public void onFinishLoadingStyle() { - if (isInitialized) { + isStyleInitialized = true; + if (isComponentInitialized) { locationLayerController.initializeComponents(options); locationCameraController.initializeOptions(options); + onLocationLayerStart(); } - onLocationLayerStart(); } @SuppressLint("MissingPermission") private void onLocationLayerStart() { - if (!isInitialized || !isComponentStarted) { + if (!isComponentInitialized || !isComponentStarted) { return; } @@ -874,7 +878,7 @@ public final class LocationComponent { } private void onLocationLayerStop() { - if (!isInitialized || !isLayerReady || !isComponentStarted) { + if (!isComponentInitialized || !isLayerReady || !isComponentStarted) { return; } @@ -891,10 +895,10 @@ public final class LocationComponent { } private void initialize(@NonNull Context context, @NonNull LocationComponentOptions options) { - if (isInitialized) { + if (isComponentInitialized) { return; } - isInitialized = true; + isComponentInitialized = true; this.options = options; mapboxMap.addOnMapClickListener(onMapClickListener); @@ -924,6 +928,10 @@ public final class LocationComponent { setRenderMode(RenderMode.NORMAL); setCameraMode(CameraMode.NONE); + if (isStyleInitialized) { + onFinishLoadingStyle(); + } + onLocationLayerStart(); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java index 0e7508ab7..b2ba5e684 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java @@ -78,7 +78,6 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV this.layerSourceProvider = layerSourceProvider; this.bitmapProvider = bitmapProvider; this.locationFeature = featureProvider.generateLocationFeature(locationFeature, options); - initializeComponents(options); setRenderMode(RenderMode.NORMAL); } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java index 3b1b87c15..8e436954c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java @@ -12,7 +12,6 @@ import android.support.annotation.Nullable; import android.view.View; import android.widget.ArrayAdapter; import android.widget.Toast; - import com.mapbox.mapboxsdk.MapStrictMode; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; @@ -25,8 +24,8 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Set; import java.util.Locale; +import java.util.Set; /** * Responsible for managing attribution interactions on the map. @@ -180,10 +179,14 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt List attributions = new ArrayList<>(); String attribution; - for (Source source : mapboxMap.getStyle().getSources()) { - attribution = source.getAttribution(); - if (!attribution.isEmpty()) { - attributions.add(source.getAttribution()); + + Style style = mapboxMap.getStyle(); + if (style != null) { + for (Source source : mapboxMap.getStyle().getSources()) { + attribution = source.getAttribution(); + if (!attribution.isEmpty()) { + attributions.add(source.getAttribution()); + } } } 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 8e76d14fc..8ec5a923b 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 @@ -25,8 +25,6 @@ import com.mapbox.mapboxsdk.MapStrictMode; import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.annotations.Annotation; -import com.mapbox.mapboxsdk.camera.CameraPosition; -import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; import com.mapbox.mapboxsdk.constants.MapboxConstants; import com.mapbox.mapboxsdk.location.LocationComponent; import com.mapbox.mapboxsdk.maps.renderer.MapRenderer; @@ -34,7 +32,6 @@ import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer import com.mapbox.mapboxsdk.maps.renderer.textureview.TextureViewMapRenderer; import com.mapbox.mapboxsdk.maps.widgets.CompassView; import com.mapbox.mapboxsdk.net.ConnectivityReceiver; -import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition; import com.mapbox.mapboxsdk.storage.FileSource; import com.mapbox.mapboxsdk.utils.BitmapUtils; @@ -484,69 +481,6 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { } } - /** - *

- * Loads a new map style from the specified URL. - *

- * {@code url} can take the following forms: - *