diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps')
2 files changed, 52 insertions, 6 deletions
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 6fcc2c199a..76870e44d9 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 @@ -44,6 +44,7 @@ import com.mapbox.mapboxsdk.net.ConnectivityReceiver; import com.mapbox.mapboxsdk.offline.OfflineGeometryRegionDefinition; import com.mapbox.mapboxsdk.offline.OfflineRegionDefinition; import com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition; +import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin; import com.mapbox.mapboxsdk.storage.FileSource; import com.mapbox.mapboxsdk.utils.BitmapUtils; @@ -178,9 +179,9 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { Transform transform = new Transform(nativeMapView, annotationManager.getMarkerViewManager(), cameraChangeDispatcher); + // MapboxMap mapboxMap = new MapboxMap(nativeMapView, transform, uiSettings, proj, registerTouchListener, annotationManager, cameraChangeDispatcher); - mapCallback.attachMapboxMap(mapboxMap); // user input @@ -194,8 +195,13 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { mapGestureDetector, cameraChangeDispatcher, getWidth(), getHeight()); mapZoomButtonController.bind(uiSettings, zoomListener); + // compass compassView.injectCompassAnimationListener(createCompassAnimationListener(cameraChangeDispatcher)); compassView.setOnClickListener(createCompassClickListener(cameraChangeDispatcher)); + + // LocationLayerPlugin + mapboxMap.injectLocationLayerPlugin(new LocationLayerPlugin(context, mapboxMap)); + // inject widgets with MapboxMap attrView.setOnClickListener(new AttributionClickListener(context, mapboxMap)); @@ -1214,11 +1220,16 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback { @Override public void onMapChanged(@MapChange int change) { - if (change == DID_FINISH_LOADING_STYLE && initialLoad) { - initialLoad = false; - mapboxMap.onPreMapReady(); - onMapReady(); - mapboxMap.onPostMapReady(); + if (change == WILL_START_LOADING_MAP) { + mapboxMap.onStartLoadingMap(); + } else if (change == DID_FINISH_LOADING_STYLE) { + if (initialLoad) { + initialLoad = false; + mapboxMap.onPreMapReady(); + onMapReady(); + mapboxMap.onPostMapReady(); + } + mapboxMap.onFinishLoadingStyle(); } else if (change == DID_FINISH_RENDERING_FRAME || change == DID_FINISH_RENDERING_FRAME_FULLY_RENDERED) { mapboxMap.onUpdateFullyRendered(); } else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 08369bb566..8892aa45fe 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -43,6 +43,7 @@ import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLng; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.log.Logger; +import com.mapbox.mapboxsdk.plugins.locationlayer.LocationLayerPlugin; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.Layer; import com.mapbox.mapboxsdk.style.light.Light; @@ -75,6 +76,7 @@ public final class MapboxMap { private final OnGesturesManagerInteractionListener onGesturesManagerInteractionListener; + private LocationLayerPlugin locationLayerPlugin; private MapboxMap.OnFpsChangedListener onFpsChangedListener; MapboxMap(NativeMapView map, Transform transform, UiSettings ui, Projection projection, @@ -110,12 +112,14 @@ public final class MapboxMap { // if user hasn't loaded a Style yet nativeMapView.setStyleUrl(Style.MAPBOX_STREETS); } + locationLayerPlugin.onStart(); } /** * Called when the hosting Activity/Fragment onStop() method is called. */ void onStop() { + locationLayerPlugin.onStop(); } /** @@ -175,6 +179,20 @@ public final class MapboxMap { } /** + * Called when the map will start loading style. + */ + void onStartLoadingMap() { + locationLayerPlugin.onStartLoadingMap(); + } + + /** + * Called the map finished loading style. + */ + void onFinishLoadingStyle() { + locationLayerPlugin.onFinishLoadingStyle(); + } + + /** * Called when the region is changing or has changed. */ void onUpdateRegionChange() { @@ -2284,6 +2302,23 @@ public final class MapboxMap { } // + // LocationLayerPlugin + // + + void injectLocationLayerPlugin(LocationLayerPlugin locationLayerPlugin) { + this.locationLayerPlugin = locationLayerPlugin; + } + + /** + * Returns an object that can be used to display user's location on the Map. + * @return the location layer + */ + @NonNull + public LocationLayerPlugin getLocationLayerPlugin() { + return locationLayerPlugin; + } + + // // Interfaces // |