summaryrefslogtreecommitdiff
path: root/platform/android
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/location/LocationLayerController.java24
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/AttributionDialogManager.java2
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapView.java1
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java237
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java228
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java4
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java14
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java28
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java40
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java24
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java108
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs2
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedSymbolLayerActivity.java27
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java7
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/AnimatedImageSourceActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java24
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java22
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt8
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GradientLineActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GridSourceActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HeatmapLayerActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java6
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java60
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java4
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java10
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java12
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java18
-rw-r--r--platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java4
53 files changed, 536 insertions, 538 deletions
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 7b465fbdfc..0e7508ab74 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
@@ -193,7 +193,7 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
}
private void setLayerVisibility(@NonNull String layerId, boolean visible) {
- Layer layer = mapboxMap.getLayer(layerId);
+ Layer layer = mapboxMap.getStyle().getLayer(layerId);
if (layer != null) {
String targetVisibility = visible ? VISIBLE : NONE;
if (!layer.getVisibility().value.equals(targetVisibility)) {
@@ -220,8 +220,8 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
addLayerToMap(accuracyLayer, BACKGROUND_LAYER);
}
- private void addLayerToMap(@NonNull Layer layer, @NonNull String idBelowLayer) {
- mapboxMap.addLayerBelow(layer, idBelowLayer);
+ private void addLayerToMap(Layer layer, @NonNull String idBelowLayer) {
+ mapboxMap.getStyle().addLayerBelow(layer, idBelowLayer);
layerMap.add(layer.getId());
}
@@ -243,11 +243,11 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
private void addLocationSource() {
locationSource = layerSourceProvider.generateSource(locationFeature);
- mapboxMap.addSource(locationSource);
+ mapboxMap.getStyle().addSource(locationSource);
}
private void refreshSource() {
- GeoJsonSource source = mapboxMap.getSourceAs(LOCATION_SOURCE);
+ GeoJsonSource source = mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE);
if (source != null) {
locationSource.setGeoJson(locationFeature);
}
@@ -272,17 +272,17 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
Bitmap backgroundStaleBitmap = bitmapProvider.generateBitmap(
options.backgroundDrawableStale(), options.backgroundStaleTintColor()
);
- mapboxMap.addImage(BACKGROUND_ICON, backgroundBitmap);
- mapboxMap.addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
+ mapboxMap.getStyle().addImage(BACKGROUND_ICON, backgroundBitmap);
+ mapboxMap.getStyle().addImage(BACKGROUND_STALE_ICON, backgroundStaleBitmap);
}
private void styleShadow(@NonNull LocationComponentOptions options) {
- mapboxMap.addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
+ mapboxMap.getStyle().addImage(SHADOW_ICON, bitmapProvider.generateShadowBitmap(options));
}
private void styleBearing(LocationComponentOptions options) {
Bitmap bearingBitmap = bitmapProvider.generateBitmap(options.bearingDrawable(), options.bearingTintColor());
- mapboxMap.addImage(BEARING_ICON, bearingBitmap);
+ mapboxMap.getStyle().addImage(BEARING_ICON, bearingBitmap);
}
private void styleAccuracy(float accuracyAlpha, @ColorInt int accuracyColor) {
@@ -306,13 +306,13 @@ final class LocationLayerController implements MapboxAnimator.OnLayerAnimationsV
options.gpsDrawable(), options.foregroundStaleTintColor()
);
}
- mapboxMap.addImage(FOREGROUND_ICON, foregroundBitmap);
- mapboxMap.addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
+ mapboxMap.getStyle().addImage(FOREGROUND_ICON, foregroundBitmap);
+ mapboxMap.getStyle().addImage(FOREGROUND_STALE_ICON, foregroundBitmapStale);
}
private void styleScaling(@NonNull LocationComponentOptions options) {
for (String layerId : layerMap) {
- Layer layer = mapboxMap.getLayer(layerId);
+ Layer layer = mapboxMap.getStyle().getLayer(layerId);
if (layer instanceof SymbolLayer) {
layer.setProperties(
iconSize(
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 c27dbd7517..3b1b87c15f 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
@@ -180,7 +180,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt
List<String> attributions = new ArrayList<>();
String attribution;
- for (Source source : mapboxMap.getSources()) {
+ 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 29235b899f..489ff62df5 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
@@ -28,7 +28,6 @@ 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.maps.Style;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.maps.renderer.MapRenderer;
import com.mapbox.mapboxsdk.maps.renderer.glsurfaceview.GLSurfaceViewMapRenderer;
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 d9ee460ec1..c0c870c2c3 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
@@ -6,7 +6,6 @@ import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Bundle;
import android.support.annotation.FloatRange;
-import android.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.Size;
@@ -21,7 +20,6 @@ import com.mapbox.android.gestures.ShoveGestureDetector;
import com.mapbox.android.gestures.StandardScaleGestureDetector;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Geometry;
-import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.Marker;
@@ -34,17 +32,12 @@ import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraUpdate;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
-import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.log.Logger;
import com.mapbox.mapboxsdk.style.expressions.Expression;
-import com.mapbox.mapboxsdk.style.layers.Layer;
-import com.mapbox.mapboxsdk.style.light.Light;
-import com.mapbox.mapboxsdk.style.sources.Source;
-import java.util.HashMap;
import java.util.List;
/**
@@ -241,222 +234,6 @@ public final class MapboxMap {
return nativeMapView.getPrefetchesTiles();
}
- /**
- * Retrieve all the layers in the style
- *
- * @return all the layers in the current style
- */
- @NonNull
- public List<Layer> getLayers() {
- return nativeMapView.getLayers();
- }
-
- /**
- * Get the layer by id
- *
- * @param layerId the layer's id
- * @return the layer, if present in the style
- */
- @Nullable
- public Layer getLayer(@NonNull String layerId) {
- return nativeMapView.getLayer(layerId);
- }
-
- /**
- * Tries to cast the Layer to T, throws ClassCastException if it's another type.
- *
- * @param layerId the layer id used to look up a layer
- * @param <T> the generic attribute of a Layer
- * @return the casted Layer, null if another type
- */
- @Nullable
- public <T extends Layer> T getLayerAs(@NonNull String layerId) {
- // noinspection unchecked
- return (T) nativeMapView.getLayer(layerId);
- }
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- */
- public void addLayer(@NonNull Layer layer) {
- nativeMapView.addLayer(layer);
- }
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- * @param below the layer id to add this layer before
- */
- public void addLayerBelow(@NonNull Layer layer, @NonNull String below) {
- nativeMapView.addLayerBelow(layer, below);
- }
-
- /**
- * Adds the layer to the map. The layer must be newly created and not added to the map before
- *
- * @param layer the layer to add
- * @param above the layer id to add this layer above
- */
- public void addLayerAbove(@NonNull Layer layer, @NonNull String above) {
- nativeMapView.addLayerAbove(layer, above);
- }
-
- /**
- * Adds the layer to the map at the specified index. The layer must be newly
- * created and not added to the map before
- *
- * @param layer the layer to add
- * @param index the index to insert the layer at
- */
- public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) {
- nativeMapView.addLayerAt(layer, index);
- }
-
- /**
- * Removes the layer. The reference is re-usable after this and can be re-added
- *
- * @param layerId the layer to remove
- * @return true if the layer was successfully removed, false - otherwise
- */
- public boolean removeLayer(@NonNull String layerId) {
- return nativeMapView.removeLayer(layerId);
- }
-
- /**
- * Removes the layer. The reference is re-usable after this and can be re-added
- *
- * @param layer the layer to remove
- * @return true if the layer was successfully removed, false - otherwise
- */
- public boolean removeLayer(@NonNull Layer layer) {
- return nativeMapView.removeLayer(layer);
- }
-
- /**
- * Removes the layer. Any other references to the layer become invalid and should not be used anymore
- *
- * @param index the layer index
- * @return true if the layer was successfully removed, false - otherwise
- */
- public boolean removeLayerAt(@IntRange(from = 0) int index) {
- return nativeMapView.removeLayerAt(index);
- }
-
- /**
- * Retrieve all the sources in the style
- *
- * @return all the sources in the current style
- */
- @NonNull
- public List<Source> getSources() {
- return nativeMapView.getSources();
- }
-
- /**
- * Retrieve a source by id
- *
- * @param sourceId the source's id
- * @return the source if present in the current style
- */
- @Nullable
- public Source getSource(@NonNull String sourceId) {
- return nativeMapView.getSource(sourceId);
- }
-
- /**
- * Tries to cast the Source to T, returns null if it's another type.
- *
- * @param sourceId the id used to look up a layer
- * @param <T> the generic type of a Source
- * @return the casted Source, null if another type
- */
- @Nullable
- public <T extends Source> T getSourceAs(@NonNull String sourceId) {
- try {
- // noinspection unchecked
- return (T) nativeMapView.getSource(sourceId);
- } catch (ClassCastException exception) {
- String message = String.format("Source: %s is a different type: ", sourceId);
- Logger.e(TAG, message, exception);
- MapStrictMode.strictModeViolation(message, exception);
- return null;
- }
- }
-
- /**
- * Adds the source to the map. The source must be newly created and not added to the map before
- *
- * @param source the source to add
- */
- public void addSource(@NonNull Source source) {
- nativeMapView.addSource(source);
- }
-
- /**
- * Removes the source, preserving the reference for re-use
- *
- * @param sourceId the source to remove
- * @return true if the source was successfully removed, false - otherwise
- */
- public boolean removeSource(@NonNull String sourceId) {
- return nativeMapView.removeSource(sourceId);
- }
-
- /**
- * Removes the source, preserving the reference for re-use
- *
- * @param source the source to remove
- * @return true if the source was successfully removed, false - otherwise
- */
- public boolean removeSource(@NonNull Source source) {
- return nativeMapView.removeSource(source);
- }
-
- /**
- * Adds an image to be used in the map's style
- *
- * @param name the name of the image
- * @param image the pre-multiplied Bitmap
- */
- public void addImage(@NonNull String name, @NonNull Bitmap image) {
- addImage(name, image, false);
- }
-
- /**
- * Adds an image to be used in the map's style
- *
- * @param name the name of the image
- * @param image the pre-multiplied Bitmap
- * @param sdf the flag indicating image is an SDF or template image
- */
- public void addImage(@NonNull String name, @NonNull Bitmap image, boolean sdf) {
- nativeMapView.addImage(name, image, sdf);
- }
-
- /**
- * Adds an images to be used in the map's style
- */
- public void addImages(@NonNull HashMap<String, Bitmap> images) {
- nativeMapView.addImages(images);
- }
-
- /**
- * Removes an image from the map's style
- *
- * @param name the name of the image to remove
- */
- public void removeImage(@NonNull String name) {
- nativeMapView.removeImage(name);
- }
-
- @Nullable
- public Bitmap getImage(@NonNull String name) {
- return nativeMapView.getImage(name);
- }
-
//
// MinZoom
//
@@ -544,20 +321,6 @@ public final class MapboxMap {
}
//
- // Light
- //
-
- /**
- * Get the global light source used to change lighting conditions on extruded fill layers.
- *
- * @return the global light source
- */
- @NonNull
- public Light getLight() {
- return nativeMapView.getLight();
- }
-
- //
// Camera API
//
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
index 8a8a351db3..9e8748ce4b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/Style.java
@@ -1,13 +1,19 @@
package com.mapbox.mapboxsdk.maps;
+import android.graphics.Bitmap;
+import android.support.annotation.IntRange;
+import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.annotation.StringDef;
import com.mapbox.mapboxsdk.style.layers.Layer;
import com.mapbox.mapboxsdk.style.layers.TransitionOptions;
+import com.mapbox.mapboxsdk.style.light.Light;
import com.mapbox.mapboxsdk.style.sources.Source;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
+import java.util.List;
public class Style {
@@ -41,11 +47,31 @@ public class Style {
// Source
//
+ /**
+ * Retrieve all the sources in the style
+ *
+ * @return all the sources in the current style
+ */
+ public List<Source> getSources() {
+ return nativeMapView.getSources();
+ }
+
+ /**
+ * Adds the source to the map. The source must be newly created and not added to the map before
+ *
+ * @param source the source to add
+ */
public void addSource(Source source) {
sources.put(source.getId(), source);
nativeMapView.addSource(source);
}
+ /**
+ * Retrieve a source by id
+ *
+ * @param id the source's id
+ * @return the source if present in the current style
+ */
public Source getSource(String id) {
Source source = sources.get(id);
if (source == null) {
@@ -54,15 +80,99 @@ public class Style {
return source;
}
+ /**
+ * Tries to cast the Source to T, throws ClassCastException if it's another type.
+ *
+ * @param sourceId the id used to look up a layer
+ * @param <T> the generic type of a Source
+ * @return the casted Source, null if another type
+ */
+ public <T extends Source> T getSourceAs(@NonNull String sourceId) {
+ // noinspection unchecked
+ if (sources.containsKey(sourceId)) {
+ return (T) sources.get(sourceId);
+ }
+ return (T) nativeMapView.getSource(sourceId);
+ }
+
+ /**
+ * Removes the source. Any references to the source become invalid and should not be used anymore
+ *
+ * @param sourceId the source to remove
+ * @return the source handle or null if the source was not present
+ */
+ @Nullable
+ public boolean removeSource(@NonNull String sourceId) {
+ sources.remove(sourceId);
+ return nativeMapView.removeSource(sourceId);
+ }
+
+ /**
+ * Removes the source, preserving the reference for re-use
+ *
+ * @param source the source to remove
+ * @return the source
+ */
+ @Nullable
+ public boolean removeSource(@NonNull Source source) {
+ sources.remove(source.getId());
+ return nativeMapView.removeSource(source);
+ }
+
//
// Layer
//
+ /**
+ * Adds the layer to the map. The layer must be newly created and not added to the map before
+ *
+ * @param layer the layer to add
+ */
public void addLayer(Layer layer) {
layers.put(layer.getId(), layer);
nativeMapView.addLayer(layer);
}
+ /**
+ * Adds the layer to the map. The layer must be newly created and not added to the map before
+ *
+ * @param layer the layer to add
+ * @param below the layer id to add this layer before
+ */
+ public void addLayerBelow(@NonNull Layer layer, @NonNull String below) {
+ layers.put(layer.getId(), layer);
+ nativeMapView.addLayerBelow(layer, below);
+ }
+
+ /**
+ * Adds the layer to the map. The layer must be newly created and not added to the map before
+ *
+ * @param layer the layer to add
+ * @param above the layer id to add this layer above
+ */
+ public void addLayerAbove(@NonNull Layer layer, @NonNull String above) {
+ layers.put(layer.getId(), layer);
+ nativeMapView.addLayerAbove(layer, above);
+ }
+
+ /**
+ * Adds the layer to the map at the specified index. The layer must be newly
+ * created and not added to the map before
+ *
+ * @param layer the layer to add
+ * @param index the index to insert the layer at
+ */
+ public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) {
+ layers.put(layer.getId(), layer);
+ nativeMapView.addLayerAt(layer, index);
+ }
+
+ /**
+ * Get the layer by id
+ *
+ * @param id the layer's id
+ * @return the layer, if present in the style
+ */
public Layer getLayer(String id) {
Layer layer = layers.get(id);
if (layer == null) {
@@ -71,10 +181,110 @@ public class Style {
return layer;
}
+ /**
+ * Tries to cast the Layer to T, throws ClassCastException if it's another type.
+ *
+ * @param layerId the layer id used to look up a layer
+ * @param <T> the generic attribute of a Layer
+ * @return the casted Layer, null if another type
+ */
+ public <T extends Layer> T getLayerAs(@NonNull String layerId) {
+ // noinspection unchecked
+ return (T) nativeMapView.getLayer(layerId);
+ }
+
+ /**
+ * Retrieve all the layers in the style
+ *
+ * @return all the layers in the current style
+ */
+ @NonNull
+ public List<Layer> getLayers() {
+ return nativeMapView.getLayers();
+ }
+
+ /**
+ * Removes the layer. Any references to the layer become invalid and should not be used anymore
+ *
+ * @param layerId the layer to remove
+ * @return the removed layer or null if not found
+ */
+ public boolean removeLayer(@NonNull String layerId) {
+ layers.remove(layerId);
+ return nativeMapView.removeLayer(layerId);
+ }
+
+ /**
+ * Removes the layer. The reference is re-usable after this and can be re-added
+ *
+ * @param layer the layer to remove
+ * @return the layer
+ */
+ public boolean removeLayer(@NonNull Layer layer) {
+ layers.remove(layer.getId());
+ return nativeMapView.removeLayer(layer);
+ }
+
+ /**
+ * Removes the layer. Any other references to the layer become invalid and should not be used anymore
+ *
+ * @param index the layer index
+ * @return the removed layer or null if not found
+ */
+ public boolean removeLayerAt(@IntRange(from = 0) int index) {
+ // TODO what about runtime added sources?
+ return nativeMapView.removeLayerAt(index);
+ }
+
//
- // Transition
+ // Image
//
+ /**
+ * Adds an image to be used in the map's style
+ *
+ * @param name the name of the image
+ * @param image the pre-multiplied Bitmap
+ */
+ public void addImage(@NonNull String name, @NonNull Bitmap image) {
+ addImage(name, image, false);
+ }
+
+ /**
+ * Adds an image to be used in the map's style
+ *
+ * @param name the name of the image
+ * @param image the pre-multiplied Bitmap
+ * @param sdf the flag indicating image is an SDF or template image
+ */
+ public void addImage(@NonNull String name, @NonNull Bitmap image, boolean sdf) {
+ nativeMapView.addImage(name, image, sdf);
+ }
+
+ /**
+ * Adds an images to be used in the map's style
+ */
+ public void addImages(@NonNull HashMap<String, Bitmap> images) {
+ nativeMapView.addImages(images);
+ }
+
+ /**
+ * Removes an image from the map's style
+ *
+ * @param name the name of the image to remove
+ */
+ public void removeImage(@NonNull String name) {
+ nativeMapView.removeImage(name);
+ }
+
+ @Nullable
+ public Bitmap getImage(@NonNull String name) {
+ return nativeMapView.getImage(name);
+ }
+
+ //
+ // Transition
+ //
/**
* <p>
@@ -102,7 +312,21 @@ public class Style {
}
//
- // Style constants
+ // Light
+ //
+
+ /**
+ * Get the light source used to change lighting conditions on extruded fill layers.
+ *
+ * @return the global light source
+ */
+ @NonNull
+ public Light getLight() {
+ return nativeMapView.getLight();
+ }
+
+ //
+ // Style URL constants
//
/**
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
index 447d51e5b1..d50dce9ca6 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java
@@ -2862,7 +2862,7 @@ public class Expression {
* </p>
* <pre>
* {@code
- * mapboxMap.addLayer(new SymbolLayer("layer-id", "source-id")
+ * mapboxMap.getStyle().addLayer(new SymbolLayer("layer-id", "source-id")
* .withProperties(
* textField(
* switchCase(
@@ -2893,7 +2893,7 @@ public class Expression {
* </p>
* <pre>
* {@code
- * mapboxMap.addLayer(new SymbolLayer("layer-id", "source-id")
+ * mapboxMap.getStyle().addLayer(new SymbolLayer("layer-id", "source-id")
* .withProperties(
* textField(
* switchCase(
diff --git a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
index 51fdf812e6..d301c5cbd2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
+++ b/platform/android/MapboxGLAndroidSDK/src/test/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.java
@@ -302,7 +302,7 @@ public class LocationLayerControllerTest {
public void onNewLatLngValue_locationFeatureIsUpdated() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -322,7 +322,7 @@ public class LocationLayerControllerTest {
public void onNewGpsBearingValue_locationFeatureIsUpdated() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -343,7 +343,7 @@ public class LocationLayerControllerTest {
public void onNewGpsBearingValue_updateIgnoredWithInvalidRenderMode() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -364,7 +364,7 @@ public class LocationLayerControllerTest {
public void onNewCompassBearingValue_locationFeatureIsUpdated() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -385,7 +385,7 @@ public class LocationLayerControllerTest {
public void onNewCompassBearingValue_updateIgnoredWithInvalidRenderMode() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -406,7 +406,7 @@ public class LocationLayerControllerTest {
public void onNewAccuracyRadiusValue_locationFeatureIsUpdated() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
@@ -426,7 +426,7 @@ public class LocationLayerControllerTest {
public void onNewAccuracyRadiusValue_updateIgnoredWithInvalidRenderMode() {
GeoJsonSource locationSource = mock(GeoJsonSource.class);
MapboxMap mapboxMap = mock(MapboxMap.class);
- when(mapboxMap.getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
+ when(mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)).thenReturn(locationSource);
LayerSourceProvider sourceProvider = buildLayerProvider();
when(sourceProvider.generateSource(any(Feature.class))).thenReturn(locationSource);
LayerBitmapProvider bitmapProvider = mock(LayerBitmapProvider.class);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
index 0554f924f2..aa666eaa25 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/LocationLayerControllerTest.kt
@@ -79,7 +79,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
component.isLocationComponentEnabled = true
component.renderMode = RenderMode.NORMAL
uiController.loopMainThreadForAtLeast(MAP_RENDER_DELAY)
- assertThat(mapboxMap.getSource(LOCATION_SOURCE), notNullValue())
+ assertThat(mapboxMap.getStyle().getSource(LOCATION_SOURCE), notNullValue())
}
}
executeComponentTest(componentAction)
@@ -220,7 +220,7 @@ class LocationLayerControllerTest : BaseActivityTest() {
assertThat(component.renderMode, `is`(equalTo(RenderMode.NORMAL)))
// Check that the Source has been re-added to the new map style
- val source: GeoJsonSource? = mapboxMap.getSourceAs(LOCATION_SOURCE)
+ val source: GeoJsonSource? = mapboxMap.getStyle().getSourceAs(LOCATION_SOURCE)
assertThat(source, notNullValue())
// Check that all layers visibilities are set to visible
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
index 7d362a6f76..9ad1e1fc37 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/location/utils/MapboxTestingUtils.kt
@@ -99,7 +99,7 @@ class MapboxTestingUtils {
fun MapboxMap.addImageFromDrawable(string: String, drawable: Drawable) {
val bitmapFromDrawable = getBitmapFromDrawable(drawable)
- this.addImage(string, bitmapFromDrawable)
+ this.style.addImage(string, bitmapFromDrawable)
}
private fun getBitmapFromDrawable(drawable: Drawable): Bitmap {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
index 773a81705d..5dc66ab77e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/geometry/GeoJsonConversionTest.java
@@ -30,12 +30,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testEmptyFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(fromGeometries(emptyList())))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -43,12 +43,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testPointFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(Point.fromLngLat(0.0,0.0)))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -56,12 +56,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testMultiPointFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -70,12 +70,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testPolygonFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(Polygon.fromLngLats(emptyList())))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -83,12 +83,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testMultiPolygonFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(fromPolygon(Polygon.fromLngLats(emptyList()))))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -96,12 +96,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testLineStringFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLngLats(emptyList())))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
@@ -109,12 +109,12 @@ public class GeoJsonConversionTest extends BaseActivityTest {
public void testMultiLineStringFeatureCollection() {
validateTestSetup();
onMapView().perform(getMapboxMapAction((uiController, mapboxMap) -> {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new CustomGeometrySource("test-id",
new CustomProvider(fromFeatures(singletonList(fromGeometry(fromLineString(fromLngLats(emptyList()))))))
)
);
- mapboxMap.addLayer(new SymbolLayer("test-id", "test-id"));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("test-id", "test-id"));
}));
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
index 09fbcb868c..b70c3e89ad 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/maps/widgets/AttributionTest.java
@@ -151,7 +151,7 @@ public class AttributionTest extends BaseActivityTest {
private void buildUrlSpans() {
onView(withId(R.id.mapView)).perform(new MapboxMapAction((uiController, view) -> {
- for (Source source : mapboxMap.getSources()) {
+ for (Source source : mapboxMap.getStyle().getSources()) {
String attributionSource = source.getAttribution();
if (!TextUtils.isEmpty(attributionSource)) {
SpannableStringBuilder htmlBuilder = (SpannableStringBuilder) Html.fromHtml(attributionSource);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
index 3dd08e1602..4398be744f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/BackgroundLayerTest.java
@@ -39,7 +39,7 @@ public class BackgroundLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- layer = mapboxMap.getLayerAs("background");
+ layer = mapboxMap.getStyle().getLayerAs("background");
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
index 00e4245587..23479b2893 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CircleLayerTest.java
@@ -39,13 +39,13 @@ public class CircleLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new CircleLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
index b60a4cff67..988cc088aa 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/CustomGeometrySourceTest.kt
@@ -39,9 +39,9 @@ class CustomGeometrySourceTest : BaseActivityTest() {
fun threadsShutdownWhenSourceRemovedTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
- mapboxMap.removeLayer(ID_GRID_LAYER)
+ mapboxMap.getStyle().removeLayer(ID_GRID_LAYER)
uiController.loopMainThreadForAtLeast(3000)
- mapboxMap.removeSource(ID_GRID_SOURCE)
+ mapboxMap.getStyle().removeSource(ID_GRID_SOURCE)
uiController.loopMainThreadForAtLeast(1000)
Assert.assertTrue("There should be no threads running when the source is removed.",
Thread.getAllStackTraces().keys.filter {
@@ -55,12 +55,12 @@ class CustomGeometrySourceTest : BaseActivityTest() {
fun threadsRestartedWhenSourceReAddedTest() {
validateTestSetup()
invoke(mapboxMap) { uiController, mapboxMap ->
- mapboxMap.removeLayer((rule.activity as GridSourceActivity).layer)
+ mapboxMap.getStyle().removeLayer((rule.activity as GridSourceActivity).layer)
uiController.loopMainThreadForAtLeast(3000)
- mapboxMap.removeSource(ID_GRID_SOURCE)
+ mapboxMap.getStyle().removeSource(ID_GRID_SOURCE)
uiController.loopMainThreadForAtLeast(1000)
- mapboxMap.addSource((rule.activity as GridSourceActivity).source)
- mapboxMap.addLayer((rule.activity as GridSourceActivity).layer)
+ mapboxMap.getStyle().addSource((rule.activity as GridSourceActivity).source)
+ mapboxMap.getStyle().addLayer((rule.activity as GridSourceActivity).layer)
uiController.loopMainThreadForAtLeast(1000)
Assert.assertTrue("Threads should be restarted when the source is re-added to the map.",
Thread.getAllStackTraces().keys.filter {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
index 7f8691d46b..cd8c1eaea6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ExpressionTest.java
@@ -242,7 +242,7 @@ public class ExpressionTest extends BaseActivityTest {
Expression expression3 = eq(literal("Łukasz"), literal("lukasz"), collator(literal(false), eq(literal(2),
literal(1))));
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
Layer layer = new CircleLayer("layer", "source")
.withProperties(circleColor(
switchCase(
@@ -250,7 +250,7 @@ public class ExpressionTest extends BaseActivityTest {
literal(ColorUtils.colorToRgbaString(Color.RED))
)
));
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
uiController.loopMainThreadForAtLeast(1000);
assertFalse(mapboxMap.queryRenderedFeatures(mapboxMap.getProjection().toScreenLocation(latLng), "layer")
.isEmpty());
@@ -282,9 +282,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry("test")
@@ -304,9 +304,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry("test", formatFontScale(1.75))
@@ -326,9 +326,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
@@ -355,9 +355,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
@@ -386,9 +386,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
@@ -421,9 +421,9 @@ public class ExpressionTest extends BaseActivityTest {
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
feature.addNumberProperty("test_property_number", 1.5);
- mapboxMap.addSource(new GeoJsonSource("source", feature));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
@@ -450,9 +450,9 @@ public class ExpressionTest extends BaseActivityTest {
Feature feature = Feature.fromGeometry(Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude()));
feature.addStringProperty("test_property", "test");
feature.addNumberProperty("test_property_number", 1.5);
- mapboxMap.addSource(new GeoJsonSource("source", feature));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", feature));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
Expression expression = format(
formatEntry(
@@ -477,9 +477,9 @@ public class ExpressionTest extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
LatLng latLng = new LatLng(51, 17);
- mapboxMap.addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("source", Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())));
SymbolLayer layer = new SymbolLayer("layer", "source");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
layer.setProperties(textField("test"));
waitForLayer(uiController, mapboxMap, latLng);
@@ -534,13 +534,13 @@ public class ExpressionTest extends BaseActivityTest {
try {
source = new GeoJsonSource("amsterdam-parks-source",
ResourceUtils.readRawResource(rule.getActivity(), R.raw.amsterdam));
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
} catch (IOException ioException) {
return;
}
// Add a fill layer
- mapboxMap.addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
+ mapboxMap.getStyle().addLayer(layer = new FillLayer("amsterdam-parks-layer", source.getId())
.withProperties(
fillColor(rgba(0.0f, 0.0f, 0.0f, 0.5f)),
fillOutlineColor(rgb(0, 0, 255)),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java
index 1f0eb25291..70f903ca3b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillExtrusionLayerTest.java
@@ -39,13 +39,13 @@ public class FillExtrusionLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new FillExtrusionLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
index f8adc50590..98a39790dd 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/FillLayerTest.java
@@ -39,13 +39,13 @@ public class FillLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new FillLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
index 124edacbd2..e21cfd8296 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/GeoJsonSourceTests.java
@@ -51,8 +51,8 @@ public class GeoJsonSourceTests extends BaseActivityTest {
} catch (IOException exception) {
Timber.e(exception);
}
- mapboxMap.addSource(source);
- mapboxMap.addLayer(new CircleLayer("layer", source.getId()));
+ mapboxMap.getStyle().addSource(source);
+ mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
});
}
@@ -61,8 +61,8 @@ public class GeoJsonSourceTests extends BaseActivityTest {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source", Point.fromLngLat(0d, 0d));
- mapboxMap.addSource(source);
- mapboxMap.addLayer(new CircleLayer("layer", source.getId()));
+ mapboxMap.getStyle().addSource(source);
+ mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
});
}
@@ -77,8 +77,8 @@ public class GeoJsonSourceTests extends BaseActivityTest {
} catch (IOException exception) {
Timber.e(exception);
}
- mapboxMap.addSource(source);
- mapboxMap.addLayer(new CircleLayer("layer", source.getId()));
+ mapboxMap.getStyle().addSource(source);
+ mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
});
}
@@ -87,8 +87,8 @@ public class GeoJsonSourceTests extends BaseActivityTest {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source");
- mapboxMap.addSource(source);
- mapboxMap.addLayer(new CircleLayer("layer", source.getId()));
+ mapboxMap.getStyle().addSource(source);
+ mapboxMap.getStyle().addLayer(new CircleLayer("layer", source.getId()));
source.setGeoJson(Point.fromLngLat(0, 0));
source.setGeoJson(Point.fromLngLat(-25, -25));
@@ -146,9 +146,9 @@ public class GeoJsonSourceTests extends BaseActivityTest {
validateTestSetup();
MapboxMapAction.invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("source");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
Layer layer = new CircleLayer("layer", source.getId());
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
try {
source.setGeoJson(Feature.fromJson(ResourceUtils.readRawResource(rule.getActivity(), resource)));
@@ -156,8 +156,8 @@ public class GeoJsonSourceTests extends BaseActivityTest {
Timber.e(exception);
}
- mapboxMap.removeLayer(layer);
- mapboxMap.removeSource(source);
+ mapboxMap.getStyle().removeLayer(layer);
+ mapboxMap.getStyle().removeSource(source);
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
index 7c084815ae..417197ee83 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HeatmapLayerTest.java
@@ -39,13 +39,13 @@ public class HeatmapLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new HeatmapLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
index 93279901b3..1259489bc0 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/HillshadeLayerTest.java
@@ -39,13 +39,13 @@ public class HillshadeLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new HillshadeLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java
index c049fabb52..6dcc527bc8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/ImageTest.java
@@ -37,7 +37,7 @@ public class ImageTest extends BaseActivityTest {
assertTrue(drawable instanceof BitmapDrawable);
Bitmap bitmapSet = ((BitmapDrawable) drawable).getBitmap();
- mapboxMap.addImage(IMAGE_ID, bitmapSet);
+ mapboxMap.getStyle().addImage(IMAGE_ID, bitmapSet);
Bitmap bitmapGet = mapboxMap.getImage(IMAGE_ID);
assertTrue(bitmapGet.sameAs(bitmapSet));
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
index 52881e2fe6..6cb05b0fd8 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LightTest.java
@@ -160,7 +160,7 @@ public class LightTest extends BaseActivityTest {
fillExtrusionBase(Expression.get("min_height")),
fillExtrusionOpacity(0.6f)
);
- mapboxMap.addLayer(fillExtrusionLayer);
+ mapboxMap.getStyle().addLayer(fillExtrusionLayer);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
index 71b52fdb71..f484095f25 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/LineLayerTest.java
@@ -39,13 +39,13 @@ public class LineLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new LineLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
index 3c8ef99319..ae334fdf29 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RasterLayerTest.java
@@ -39,13 +39,13 @@ public class RasterLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new RasterLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
index a1b1317a01..8937456b09 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/RuntimeStyleTests.java
@@ -66,7 +66,7 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Override
public void perform(UiController uiController, View view) {
- List<Layer> layers = mapboxMap.getLayers();
+ List<Layer> layers = mapboxMap.getStyle().getLayers();
assertNotNull(layers);
assertTrue(layers.size() > 0);
for (Layer layer : layers) {
@@ -89,12 +89,12 @@ public class RuntimeStyleTests extends BaseActivityTest {
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- List<Layer> layers = mapboxMap.getLayers();
- Source source = mapboxMap.getSources().get(0);
+ List<Layer> layers = mapboxMap.getStyle().getLayers();
+ Source source = mapboxMap.getStyle().getSources().get(0);
// Test inserting with invalid above-id
try {
- mapboxMap.addLayerAbove(new CircleLayer("invalid-id-layer-test", source.getId()), "no-such-layer-here-man");
+ mapboxMap.getStyle().addLayerAbove(new CircleLayer("invalid-id-layer-test", source.getId()), "no-such-layer-here-man");
fail("Should have thrown exception");
} catch (CannotAddLayerException ex) {
// Yeah
@@ -103,14 +103,14 @@ public class RuntimeStyleTests extends BaseActivityTest {
// Insert as last
CircleLayer last = new CircleLayer("this is the last one", source.getId());
- mapboxMap.addLayerAbove(last, layers.get(layers.size() - 1).getId());
- layers = mapboxMap.getLayers();
+ mapboxMap.getStyle().addLayerAbove(last, layers.get(layers.size() - 1).getId());
+ layers = mapboxMap.getStyle().getLayers();
assertEquals(last.getId(), layers.get(layers.size() - 1).getId());
// Insert
CircleLayer second = new CircleLayer("this is the second one", source.getId());
- mapboxMap.addLayerAbove(second, layers.get(0).getId());
- layers = mapboxMap.getLayers();
+ mapboxMap.getStyle().addLayerAbove(second, layers.get(0).getId());
+ layers = mapboxMap.getStyle().getLayers();
assertEquals(second.getId(), layers.get(1).getId());
}
});
@@ -124,14 +124,14 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Override
public void perform(UiController uiController, View view) {
// Remove by index
- Layer firstLayer = mapboxMap.getLayers().get(0);
- boolean removed = mapboxMap.removeLayerAt(0);
+ Layer firstLayer = mapboxMap.getStyle().getLayers().get(0);
+ boolean removed = mapboxMap.getStyle().removeLayerAt(0);
assertTrue(removed);
assertNotNull(firstLayer);
// Test remove by index bounds checks
Timber.i("Remove layer at index > size");
- assertFalse(mapboxMap.removeLayerAt(Integer.MAX_VALUE));
+ assertNull(mapboxMap.getStyle().removeLayerAt(Integer.MAX_VALUE));
}
});
}
@@ -141,12 +141,12 @@ public class RuntimeStyleTests extends BaseActivityTest {
onView(withId(R.id.mapView)).perform(new BaseViewAction() {
@Override
public void perform(UiController uiController, View view) {
- List<Layer> layers = mapboxMap.getLayers();
- Source source = mapboxMap.getSources().get(0);
+ List<Layer> layers = mapboxMap.getStyle().getLayers();
+ Source source = mapboxMap.getStyle().getSources().get(0);
// Test inserting out of range
try {
- mapboxMap.addLayerAt(new CircleLayer("invalid-id-layer-test", source.getId()), layers.size());
+ mapboxMap.getStyle().addLayerAt(new CircleLayer("invalid-id-layer-test", source.getId()), layers.size());
fail("Should have thrown exception");
} catch (CannotAddLayerException ex) {
// Yeah
@@ -155,14 +155,14 @@ public class RuntimeStyleTests extends BaseActivityTest {
// Insert at current last position
CircleLayer last = new CircleLayer("this is the last one", source.getId());
- mapboxMap.addLayerAt(last, layers.size() - 1);
- layers = mapboxMap.getLayers();
+ mapboxMap.getStyle().addLayerAt(last, layers.size() - 1);
+ layers = mapboxMap.getStyle().getLayers();
assertEquals(last.getId(), layers.get(layers.size() - 2).getId());
// Insert at start
CircleLayer second = new CircleLayer("this is the first one", source.getId());
- mapboxMap.addLayerAt(second, 0);
- layers = mapboxMap.getLayers();
+ mapboxMap.getStyle().addLayerAt(second, 0);
+ layers = mapboxMap.getStyle().getLayers();
assertEquals(second.getId(), layers.get(0).getId());
}
});
@@ -176,7 +176,7 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Override
public void perform(UiController uiController, View view) {
- List<Source> sources = mapboxMap.getSources();
+ List<Source> sources = mapboxMap.getStyle().getSources();
assertNotNull(sources);
assertTrue(sources.size() > 0);
for (Source source : sources) {
@@ -191,34 +191,34 @@ public class RuntimeStyleTests extends BaseActivityTest {
public void testAddRemoveSource() {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
- mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
- mapboxMap.removeSource("my-source");
+ mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+ mapboxMap.getStyle().removeSource("my-source");
// Add initial source
- mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+ mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
// Remove
- boolean removeOk = mapboxMap.removeSource("my-source");
+ boolean removeOk = mapboxMap.getStyle().removeSource("my-source");
assertTrue(removeOk);
- assertNull(mapboxMap.getLayer("my-source"));
+ assertNull(mapboxMap.getStyle().getLayer("my-source"));
// Add
Source source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// Remove, preserving the reference
- mapboxMap.removeSource(source);
+ mapboxMap.getStyle().removeSource(source);
// Re-add the reference...
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// Ensure it's there
- Assert.assertNotNull(mapboxMap.getSource(source.getId()));
+ Assert.assertNotNull(mapboxMap.getStyle().getSource(source.getId()));
// Test adding a duplicate source
try {
Source source2 = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source2);
+ mapboxMap.getStyle().addSource(source2);
fail("Should not have been allowed to add a source with a duplicate id");
} catch (CannotAddSourceException cannotAddSourceException) {
// OK
@@ -232,7 +232,7 @@ public class RuntimeStyleTests extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
VectorSource source = new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
});
}
@@ -242,7 +242,7 @@ public class RuntimeStyleTests extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
RasterSource source = new RasterSource("my-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
assertEquals("mapbox://mapbox.mapbox-terrain-v2", source.getUrl());
});
}
@@ -252,7 +252,7 @@ public class RuntimeStyleTests extends BaseActivityTest {
validateTestSetup();
invoke(mapboxMap, (uiController, mapboxMap) -> {
GeoJsonSource source = new GeoJsonSource("my-source");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
assertNull(source.getUrl());
try {
source.setUrl(new URL("http://mapbox.com/my-file.json"));
@@ -271,10 +271,10 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Override
public void perform(UiController uiController, View view) {
- mapboxMap.addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
- mapboxMap.addLayer(new LineLayer("my-layer", "my-source"));
- mapboxMap.removeSource("my-source");
- assertNotNull(mapboxMap.getSource("my-source"));
+ mapboxMap.getStyle().addSource(new VectorSource("my-source", "mapbox://mapbox.mapbox-terrain-v2"));
+ mapboxMap.getStyle().addLayer(new LineLayer("my-layer", "my-source"));
+ mapboxMap.getStyle().removeSource("my-source");
+ assertNotNull(mapboxMap.getStyle().getSource("my-source"));
}
});
@@ -282,28 +282,28 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Test
public void testRemoveNonExistingSource() {
- invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.removeSource("source"));
+ invoke(mapboxMap, (uiController, mapboxMap) -> mapboxMap.getStyle().removeSource("source"));
}
@Test
public void testRemoveNonExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
- assertFalse(mapboxMap.removeLayer("layer"));
- assertFalse(mapboxMap.removeLayerAt(mapboxMap.getLayers().size() + 1));
- assertFalse(mapboxMap.removeLayerAt(-1));
+ assertFalse(mapboxMap.getStyle().removeLayer("layer"));
+ assertFalse(mapboxMap.getStyle().removeLayerAt(mapboxMap.getStyle().getLayers().size() + 1));
+ assertFalse(mapboxMap.getStyle().removeLayerAt(-1));
});
}
@Test
public void testRemoveExistingLayer() {
invoke(mapboxMap, (uiController, mapboxMap) -> {
- Layer firstLayer = mapboxMap.getLayers().get(0);
- assertTrue(mapboxMap.removeLayer(firstLayer));
+ Layer firstLayer = mapboxMap.getStyle().getLayers().get(0);
+ assertTrue(mapboxMap.getStyle().removeLayer(firstLayer));
- firstLayer = mapboxMap.getLayers().get(0);
- assertTrue(mapboxMap.removeLayer(firstLayer.getId()));
+ firstLayer = mapboxMap.getStyle().getLayers().get(0);
+ assertTrue(mapboxMap.getStyle().removeLayer(firstLayer.getId()));
- assertTrue(mapboxMap.removeLayerAt(0));
+ assertTrue(mapboxMap.getStyle().removeLayerAt(0));
});
}
@@ -332,37 +332,37 @@ public class RuntimeStyleTests extends BaseActivityTest {
@Override
public void perform(UiController uiController, View view) {
// Get initial
- assertNotNull(mapboxMap.getLayer("building"));
+ assertNotNull(mapboxMap.getStyle().getLayer("building"));
// Remove
- boolean removed = mapboxMap.removeLayer("building");
+ boolean removed = mapboxMap.getStyle().removeLayer("building");
assertTrue(removed);
- assertNull(mapboxMap.getLayer("building"));
+ assertNull(mapboxMap.getStyle().getLayer("building"));
// Add
FillLayer layer = new FillLayer("building", "composite");
layer.setSourceLayer("building");
- mapboxMap.addLayer(layer);
- assertNotNull(mapboxMap.getLayer("building"));
+ mapboxMap.getStyle().addLayer(layer);
+ assertNotNull(mapboxMap.getStyle().getLayer("building"));
// Assure the reference still works
layer.setProperties(PropertyFactory.visibility(Property.VISIBLE));
// Remove, preserving the reference
- mapboxMap.removeLayer(layer);
+ mapboxMap.getStyle().removeLayer(layer);
// Property setters should still work
layer.setProperties(PropertyFactory.fillColor(Color.RED));
// Re-add the reference...
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Ensure it's there
- Assert.assertNotNull(mapboxMap.getLayer(layer.getId()));
+ Assert.assertNotNull(mapboxMap.getStyle().getLayer(layer.getId()));
// Test adding a duplicate layer
try {
- mapboxMap.addLayer(new FillLayer("building", "composite"));
+ mapboxMap.getStyle().addLayer(new FillLayer("building", "composite"));
fail("Should not have been allowed to add a layer with a duplicate id");
} catch (CannotAddLayerException cannotAddLayerException) {
// OK
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
index f7be4f7b10..755876cd14 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java
@@ -41,13 +41,13 @@ public class SymbolLayerTest extends BaseActivityTest {
private void setupLayer() {
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new SymbolLayer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
index 2471ca8a98..14ad359dbf 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/layer.junit.ejs
@@ -48,18 +48,18 @@ public class <%- camelize(type) %>LayerTest extends BaseActivityTest {
<% if (type === 'background') { -%>
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- layer = mapboxMap.getLayerAs("background");
+ layer = mapboxMap.getStyle().getLayerAs("background");
});
<% } else { -%>
Timber.i("Retrieving layer");
invoke(mapboxMap, (uiController, mapboxMap) -> {
- if ((layer = mapboxMap.getLayerAs("my-layer")) == null) {
+ if ((layer = mapboxMap.getStyle().getLayerAs("my-layer")) == null) {
Timber.i("Adding layer");
layer = new <%- camelize(type) %>Layer("my-layer", "composite");
layer.setSourceLayer("composite");
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Layer reference is now stale, get new reference
- layer = mapboxMap.getLayerAs("my-layer");
+ layer = mapboxMap.getStyle().getLayerAs("my-layer");
}
});
<% } -%>
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
index c35168bb7a..0f2232057d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/light.junit.ejs
@@ -120,7 +120,7 @@ public class LightTest extends BaseActivityTest {
fillExtrusionBase(Expression.get("min_height")),
fillExtrusionOpacity(0.6f)
);
- mapboxMap.addLayer(fillExtrusionLayer);
+ mapboxMap.getStyle().addLayer(fillExtrusionLayer);
}
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedSymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedSymbolLayerActivity.java
index 27303901a0..118b9ddec3 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedSymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/annotation/AnimatedSymbolLayerActivity.java
@@ -18,6 +18,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.geometry.LatLngBounds;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
import com.mapbox.mapboxsdk.testapp.R;
@@ -56,6 +57,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
private MapView mapView;
private MapboxMap mapboxMap;
+ private Style style;
private List<Car> randomCars = new ArrayList<>();
private GeoJsonSource randomCarSource;
@@ -72,8 +74,9 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
- mapView.getMapAsync(mapboxMap -> {
- AnimatedSymbolLayerActivity.this.mapboxMap = mapboxMap;
+ mapView.getMapAsync(map -> {
+ this.mapboxMap = map;
+ this.style = mapboxMap.getStyle();
setupCars();
animateRandomRoutes();
animateTaxi();
@@ -180,7 +183,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
}
private void updatePassengerSource() {
- GeoJsonSource source = mapboxMap.getSourceAs(PASSENGER_SOURCE);
+ GeoJsonSource source = mapboxMap.getStyle().getSourceAs(PASSENGER_SOURCE);
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {
Feature.fromGeometry(
Point.fromLngLat(
@@ -256,8 +259,8 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
}
randomCarSource = new GeoJsonSource(RANDOM_CAR_SOURCE, featuresFromRoutes());
- mapboxMap.addSource(randomCarSource);
- mapboxMap.addImage(RANDOM_CAR_IMAGE_ID,
+ style.addSource(randomCarSource);
+ mapboxMap.getStyle().addImage(RANDOM_CAR_IMAGE_ID,
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_car_top)).getBitmap());
SymbolLayer symbolLayer = new SymbolLayer(RANDOM_CAR_LAYER, RANDOM_CAR_SOURCE);
@@ -268,7 +271,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
iconIgnorePlacement(true)
);
- mapboxMap.addLayerBelow(symbolLayer, WATERWAY_LAYER_ID);
+ style.addLayerBelow(symbolLayer, WATERWAY_LAYER_ID);
}
private void addPassenger() {
@@ -282,11 +285,11 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
)
});
- mapboxMap.addImage(PASSENGER,
+ mapboxMap.getStyle().addImage(PASSENGER,
((BitmapDrawable) getResources().getDrawable(R.drawable.icon_burned)).getBitmap());
GeoJsonSource geoJsonSource = new GeoJsonSource(PASSENGER_SOURCE, featureCollection);
- mapboxMap.addSource(geoJsonSource);
+ style.addSource(geoJsonSource);
SymbolLayer symbolLayer = new SymbolLayer(PASSENGER_LAYER, PASSENGER_SOURCE);
symbolLayer.withProperties(
@@ -294,7 +297,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
iconIgnorePlacement(true),
iconAllowOverlap(true)
);
- mapboxMap.addLayerBelow(symbolLayer, RANDOM_CAR_LAYER);
+ style.addLayerBelow(symbolLayer, RANDOM_CAR_LAYER);
}
private void addMainCar() {
@@ -308,10 +311,10 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
FeatureCollection featureCollection = FeatureCollection.fromFeatures(new Feature[] {feature});
taxi = new Car(feature, passenger, getDuration());
- mapboxMap.addImage(TAXI,
+ mapboxMap.getStyle().addImage(TAXI,
((BitmapDrawable) getResources().getDrawable(R.drawable.ic_taxi_top)).getBitmap());
taxiSource = new GeoJsonSource(TAXI_SOURCE, featureCollection);
- mapboxMap.addSource(taxiSource);
+ style.addSource(taxiSource);
SymbolLayer symbolLayer = new SymbolLayer(TAXI_LAYER, TAXI_SOURCE);
symbolLayer.withProperties(
@@ -321,7 +324,7 @@ public class AnimatedSymbolLayerActivity extends AppCompatActivity {
iconIgnorePlacement(true)
);
- mapboxMap.addLayer(symbolLayer);
+ style.addLayer(symbolLayer);
}
private LatLng getLatLngInBounds() {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
index 7685dee840..c471621286 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/customlayer/CustomLayerActivity.java
@@ -11,6 +11,7 @@ import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.CustomLayer;
import com.mapbox.mapboxsdk.testapp.R;
import com.mapbox.mapboxsdk.testapp.model.customlayer.ExampleCustomLayer;
@@ -52,14 +53,15 @@ public class CustomLayerActivity extends AppCompatActivity {
}
private void swapCustomLayer() {
+ Style style = mapboxMap.getStyle();
if (customLayer != null) {
- mapboxMap.removeLayer(customLayer);
+ style.removeLayer(customLayer);
customLayer = null;
fab.setImageResource(R.drawable.ic_layers);
} else {
customLayer = new CustomLayer("custom",
ExampleCustomLayer.createContext());
- mapboxMap.addLayerBelow(customLayer, "building");
+ style.addLayerBelow(customLayer, "building");
fab.setImageResource(R.drawable.ic_layers_clear);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
index 7953824c36..9281526352 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxHighlightActivity.java
@@ -11,6 +11,7 @@ import com.mapbox.geojson.Feature;
import com.mapbox.geojson.FeatureCollection;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -47,10 +48,12 @@ public class QueryRenderedFeaturesBoxHighlightActivity extends AppCompatActivity
mapView.getMapAsync(mapboxMap -> {
QueryRenderedFeaturesBoxHighlightActivity.this.mapboxMap = mapboxMap;
+ Style style = mapboxMap.getStyle();
+
// Add layer / source
final GeoJsonSource source = new GeoJsonSource("highlighted-shapes-source");
- mapboxMap.addSource(source);
- mapboxMap.addLayer(
+ style.addSource(source);
+ style.addLayer(
new FillLayer("highlighted-shapes-layer", "highlighted-shapes-source")
.withProperties(fillColor(Color.RED))
);
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
index 46409d1893..6bb1cb6dee 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QueryRenderedFeaturesBoxSymbolCountActivity.java
@@ -47,18 +47,18 @@ public class QueryRenderedFeaturesBoxSymbolCountActivity extends AppCompatActivi
// Add a symbol layer (also works with annotations)
try {
- mapboxMap.addSource(new GeoJsonSource("symbols-source", ResourceUtils.readRawResource(
+ mapboxMap.getStyle().addSource(new GeoJsonSource("symbols-source", ResourceUtils.readRawResource(
QueryRenderedFeaturesBoxSymbolCountActivity.this, R.raw.test_points_utrecht)));
} catch (IOException ioException) {
Timber.e(ioException, "Could not load geojson");
return;
}
- mapboxMap.addImage(
+ mapboxMap.getStyle().addImage(
"test-icon",
BitmapFactory.decodeResource(getResources(),
R.drawable.mapbox_marker_icon_default)
);
- mapboxMap.addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
+ mapboxMap.getStyle().addLayer(new SymbolLayer("symbols-layer", "symbols-source").withProperties(iconImage("test-icon")));
selectionBox.setOnClickListener(view -> {
// Query
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java
index 59cad6d816..d17a4ad9e5 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/feature/QuerySourceFeaturesActivity.java
@@ -48,14 +48,14 @@ public class QuerySourceFeaturesActivity extends AppCompatActivity {
Feature.fromGeometry(Point.fromLngLat(17.3, 51), properties),
Feature.fromGeometry(Point.fromLngLat(17.4, 51), properties),
}));
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
Expression visible = eq(get("key1"), literal("value1"));
Expression invisible = neq(get("key1"), literal("value1"));
CircleLayer layer = new CircleLayer("test-layer", source.getId())
.withFilter(visible);
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Add a click listener
mapboxMap.addOnMapClickListener(point -> {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
index 8e3bd8113b..5f90244ff4 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/maplayout/DebugModeActivity.java
@@ -85,7 +85,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
mapView.addOnDidFinishLoadingStyleListener(() -> {
if (mapboxMap != null) {
- setupNavigationView(mapboxMap.getLayers());
+ setupNavigationView(mapboxMap.getStyle().getLayers());
}
});
@@ -99,9 +99,7 @@ public class DebugModeActivity extends AppCompatActivity implements OnMapReadyCa
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
- setupNavigationView(mapboxMap.getLayers());
-
- setupNavigationView(mapboxMap.getLayers());
+ setupNavigationView(mapboxMap.getStyle().getLayers());
setupZoomView();
setFpsView();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/AnimatedImageSourceActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/AnimatedImageSourceActivity.java
index 1014af25db..b481c97e5a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/AnimatedImageSourceActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/AnimatedImageSourceActivity.java
@@ -58,11 +58,11 @@ public class AnimatedImageSourceActivity extends AppCompatActivity implements On
new LatLng(46.437, -71.516),
new LatLng(37.936, -71.516),
new LatLng(37.936, -80.425));
- mapboxMap.addSource(new ImageSource(ID_IMAGE_SOURCE, quad, R.drawable.southeast_radar_0));
+ mapboxMap.getStyle().addSource(new ImageSource(ID_IMAGE_SOURCE, quad, R.drawable.southeast_radar_0));
// add layer
RasterLayer layer = new RasterLayer(ID_IMAGE_LAYER, ID_IMAGE_SOURCE);
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// loop refresh geojson
handler = new Handler();
@@ -137,7 +137,7 @@ public class AnimatedImageSourceActivity extends AppCompatActivity implements On
@Override
public void run() {
- ((ImageSource) mapboxMap.getSource(ID_IMAGE_SOURCE)).setImage(drawables[drawableIndex++]);
+ ((ImageSource) mapboxMap.getStyle().getSource(ID_IMAGE_SOURCE)).setImage(drawables[drawableIndex++]);
if (drawableIndex > 3) {
drawableIndex = 0;
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java
index 238a86a4b9..1534b21956 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/BuildingFillExtrusionActivity.java
@@ -8,6 +8,7 @@ import android.view.MenuItem;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.expressions.Expression;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.layers.Property;
@@ -46,12 +47,13 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
- setupBuildings();
+ Style style = map.getStyle();
+ setupBuildings(style);
setupLight();
});
}
- private void setupBuildings() {
+ private void setupBuildings(Style style) {
FillExtrusionLayer fillExtrusionLayer = new FillExtrusionLayer("3d-buildings", "composite");
fillExtrusionLayer.setSourceLayer("building");
fillExtrusionLayer.setFilter(eq(get("extrude"), literal("true")));
@@ -62,11 +64,11 @@ public class BuildingFillExtrusionActivity extends AppCompatActivity {
fillExtrusionBase(Expression.get("min_height")),
fillExtrusionOpacity(0.9f)
);
- mapboxMap.addLayer(fillExtrusionLayer);
+ style.addLayer(fillExtrusionLayer);
}
private void setupLight() {
- light = mapboxMap.getLight();
+ light = mapboxMap.getStyle().getLight();
findViewById(R.id.fabLightPosition).setOnClickListener(v -> {
isInitPosition = !isInitPosition;
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
index 6d2f698ffd..59b5ee99aa 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CircleLayerActivity.java
@@ -87,7 +87,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
} catch (MalformedURLException exception) {
Timber.e(exception, "That's not an url... ");
}
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
}
private void addBusStopCircleLayer() {
@@ -96,7 +96,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
circleColor(Color.parseColor("#FF9800")),
circleRadius(2.0f)
);
- mapboxMap.addLayerBelow(layer, "waterway-label");
+ mapboxMap.getStyle().addLayerBelow(layer, "waterway-label");
}
private void initFloatingActionButtons() {
@@ -128,13 +128,13 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
}
private void removeOldSource() {
- mapboxMap.removeSource(SOURCE_ID);
- mapboxMap.removeLayer(LAYER_ID);
+ mapboxMap.getStyle().removeSource(SOURCE_ID);
+ mapboxMap.getStyle().removeLayer(LAYER_ID);
}
private void addClusteredSource() {
try {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new GeoJsonSource(SOURCE_ID_CLUSTER,
new URL(URL_BUS_ROUTES),
new GeoJsonOptions()
@@ -159,7 +159,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
iconImage("bus-15")
);
- mapboxMap.addLayer(unclustered);
+ mapboxMap.getStyle().addLayer(unclustered);
for (int i = 0; i < layers.length; i++) {
// Add some nice circles
@@ -179,7 +179,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
lt(pointCount, literal(layers[i - 1][0]))
)
);
- mapboxMap.addLayer(circles);
+ mapboxMap.getStyle().addLayer(circles);
}
// Add the count labels
@@ -191,7 +191,7 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
textIgnorePlacement(true),
textAllowOverlap(true)
);
- mapboxMap.addLayer(count);
+ mapboxMap.getStyle().addLayer(count);
}
private void removeFabs() {
@@ -206,8 +206,8 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
}
private void removeBusStop() {
- mapboxMap.removeLayer(layer);
- mapboxMap.removeSource(source);
+ mapboxMap.getStyle().removeLayer(layer);
+ mapboxMap.getStyle().removeSource(source);
}
private void loadNewStyle() {
@@ -218,8 +218,8 @@ public class CircleLayerActivity extends AppCompatActivity implements View.OnCli
}
private void addBusStop() {
- mapboxMap.addLayer(layer);
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addLayer(layer);
+ mapboxMap.getStyle().addSource(source);
}
private String getNextStyle() {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
index e5b98ff63e..f9b6b70d56 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/CustomSpriteActivity.java
@@ -58,7 +58,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
if (point == null) {
Timber.i("First click -> Car");
// Add an icon to reference later
- mapboxMap.addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
+ mapboxMap.getStyle().addImage(CUSTOM_ICON, BitmapFactory.decodeResource(getResources(), R.drawable.ic_car_top));
// Add a source with a geojson point
point = Point.fromLngLat(13.400972d, 52.519003d);
@@ -66,7 +66,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
"point",
FeatureCollection.fromFeatures(new Feature[] {Feature.fromGeometry(point)})
);
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// Add a symbol layer that references that point source
layer = new SymbolLayer("layer", "point");
@@ -78,7 +78,7 @@ public class CustomSpriteActivity extends AppCompatActivity {
);
// lets add a circle below labels!
- mapboxMap.addLayerBelow(layer, "waterway-label");
+ mapboxMap.getStyle().addLayerBelow(layer, "waterway-label");
fab.setImageResource(R.drawable.ic_directions_car_black);
} else {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
index ef8ec3af78..9fabcbbb42 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DataDrivenStyleActivity.java
@@ -167,7 +167,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addExponentialZoomFunction() {
Timber.i("Add exponential zoom function");
- FillLayer layer = mapboxMap.getLayerAs("water");
+ FillLayer layer = mapboxMap.getStyle().getLayerAs("water");
assert layer != null;
layer.setProperties(
fillColor(
@@ -185,7 +185,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addIntervalZoomFunction() {
Timber.i("Add interval zoom function");
- FillLayer layer = mapboxMap.getLayerAs("water");
+ FillLayer layer = mapboxMap.getStyle().getLayerAs("water");
assert layer != null;
layer.setProperties(
fillColor(
@@ -203,7 +203,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addExponentialSourceFunction() {
Timber.i("Add exponential source function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -222,7 +222,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addCategoricalSourceFunction() {
Timber.i("Add categorical source function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -241,7 +241,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addIdentitySourceFunction() {
Timber.i("Add identity source function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillOpacity(
@@ -254,7 +254,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addIntervalSourceFunction() {
Timber.i("Add interval source function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -273,7 +273,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addCompositeExponentialFunction() {
Timber.i("Add composite exponential function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -310,7 +310,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addCompositeIntervalFunction() {
Timber.i("Add composite interval function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -347,7 +347,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
private void addCompositeCategoricalFunction() {
Timber.i("Add composite categorical function");
- FillLayer layer = mapboxMap.getLayerAs(AMSTERDAM_PARKS_LAYER);
+ FillLayer layer = mapboxMap.getStyle().getLayerAs(AMSTERDAM_PARKS_LAYER);
assert layer != null;
layer.setProperties(
fillColor(
@@ -448,7 +448,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
Source source;
try {
source = new GeoJsonSource("amsterdam-parks-source", ResourceUtils.readRawResource(this, R.raw.amsterdam));
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
} catch (IOException ioException) {
Toast.makeText(
DataDrivenStyleActivity.this,
@@ -458,7 +458,7 @@ public class DataDrivenStyleActivity extends AppCompatActivity {
}
// Add a fill layer
- mapboxMap.addLayer(new FillLayer(AMSTERDAM_PARKS_LAYER, source.getId())
+ mapboxMap.getStyle().addLayer(new FillLayer(AMSTERDAM_PARKS_LAYER, source.getId())
.withProperties(
fillColor(color(Color.GREEN)),
fillOutlineColor(rgb(0, 0, 255)),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
index 12aa665bee..6b55a73b4c 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/DraggableMarkerActivity.kt
@@ -67,10 +67,12 @@ class DraggableMarkerActivity : AppCompatActivity() {
mapView.getMapAsync { mapboxMap ->
this.mapboxMap = mapboxMap
+ val style = mapboxMap.style
+
// Setting up markers icon, source and layer
- mapboxMap.addImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
- mapboxMap.addSource(source)
- mapboxMap.addLayer(layer)
+ mapboxMap.getStyle().addImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
+ style.addSource(source)
+ style.addLayer(layer)
// Add initial markers
addMarker(LatLng(52.407210, 16.924324))
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java
index b7f6b10b0d..1ef47a852a 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/FillExtrusionActivity.java
@@ -52,9 +52,9 @@ public class FillExtrusionActivity extends AppCompatActivity {
Polygon domTower = Polygon.fromLngLats(lngLats);
GeoJsonSource source = new GeoJsonSource("extrusion-source", domTower);
- map.addSource(source);
+ map.getStyle().addSource(source);
- mapboxMap.addLayer(
+ mapboxMap.getStyle().addLayer(
new FillExtrusionLayer("extrusion-layer", source.getId())
.withProperties(
fillExtrusionHeight(40f),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
index aefb0395d3..713d0b7451 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GeoJsonClusteringActivity.java
@@ -59,14 +59,14 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
setContentView(R.layout.activity_geojson_clustering);
// Initialize map as normal
- mapView = (MapView) findViewById(R.id.mapView);
+ mapView = findViewById(R.id.mapView);
// noinspection ConstantConditions
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(37.7749, 122.4194), 0));
- mapboxMap.addImage(
+ mapboxMap.getStyle().addImage(
"icon-id",
BitmapUtils.getBitmapFromDrawable(getResources().getDrawable(R.drawable.ic_hearing_black_24dp)),
true
@@ -132,7 +132,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
private void addClusteredGeoJsonSource() {
// Add a clustered source
try {
- mapboxMap.addSource(
+ mapboxMap.getStyle().addSource(
new GeoJsonSource("earthquakes",
new URL("https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"),
new GeoJsonOptions()
@@ -169,7 +169,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
)
);
unclustered.setFilter(has("mag"));
- mapboxMap.addLayer(unclustered);
+ mapboxMap.getStyle().addLayer(unclustered);
for (int i = 0; i < layers.length; i++) {
// Add some nice circles
@@ -189,7 +189,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
lt(pointCount, literal(layers[i - 1][0]))
)
);
- mapboxMap.addLayer(circles);
+ mapboxMap.getStyle().addLayer(circles);
}
// Add the count labels
@@ -201,7 +201,7 @@ public class GeoJsonClusteringActivity extends AppCompatActivity {
textIgnorePlacement(true),
textAllowOverlap(true)
);
- mapboxMap.addLayer(count);
+ mapboxMap.getStyle().addLayer(count);
// Zoom out to start
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GradientLineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GradientLineActivity.java
index 1a4632505b..1ecbab0742 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GradientLineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GradientLineActivity.java
@@ -54,8 +54,8 @@ public class GradientLineActivity extends AppCompatActivity implements OnMapRead
try {
String geoJson = ResourceUtils.readRawResource(GradientLineActivity.this, R.raw.test_line_gradient_feature);
- mapboxMap.addSource(new GeoJsonSource(LINE_SOURCE, geoJson, new GeoJsonOptions().withLineMetrics(true)));
- mapboxMap.addLayer(new LineLayer("gradient", LINE_SOURCE)
+ mapboxMap.getStyle().addSource(new GeoJsonSource(LINE_SOURCE, geoJson, new GeoJsonOptions().withLineMetrics(true)));
+ mapboxMap.getStyle().addLayer(new LineLayer("gradient", LINE_SOURCE)
.withProperties(
lineGradient(interpolate(
linear(), lineProgress(),
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GridSourceActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GridSourceActivity.java
index 195aa63edd..791f72ce24 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GridSourceActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/GridSourceActivity.java
@@ -106,7 +106,7 @@ public class GridSourceActivity extends AppCompatActivity implements OnMapReadyC
// add source
source = new CustomGeometrySource(ID_GRID_SOURCE, new GridProvider());
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// add layer
layer = new LineLayer(ID_GRID_LAYER, ID_GRID_SOURCE);
@@ -114,7 +114,7 @@ public class GridSourceActivity extends AppCompatActivity implements OnMapReadyC
lineColor(Color.parseColor("#000000"))
);
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HeatmapLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HeatmapLayerActivity.java
index 52509e3297..c8d83d433f 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HeatmapLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HeatmapLayerActivity.java
@@ -65,7 +65,7 @@ public class HeatmapLayerActivity extends AppCompatActivity {
private void addEarthquakeSource() {
try {
- mapboxMap.addSource(new GeoJsonSource(EARTHQUAKE_SOURCE_ID, new URL(EARTHQUAKE_SOURCE_URL)));
+ mapboxMap.getStyle().addSource(new GeoJsonSource(EARTHQUAKE_SOURCE_ID, new URL(EARTHQUAKE_SOURCE_URL)));
} catch (MalformedURLException malformedUrlException) {
Timber.e(malformedUrlException, "That's not an url... ");
}
@@ -130,7 +130,7 @@ public class HeatmapLayerActivity extends AppCompatActivity {
)
);
- mapboxMap.addLayerAbove(layer, "waterway-label");
+ mapboxMap.getStyle().addLayerAbove(layer, "waterway-label");
}
private void addCircleLayer() {
@@ -179,7 +179,7 @@ public class HeatmapLayerActivity extends AppCompatActivity {
circleStrokeWidth(1.0f)
);
- mapboxMap.addLayerBelow(circleLayer, HEATMAP_LAYER_ID);
+ mapboxMap.getStyle().addLayerBelow(circleLayer, HEATMAP_LAYER_ID);
}
@Override
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java
index 066446652b..601afa399d 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/HillshadeLayerActivity.java
@@ -33,10 +33,10 @@ public class HillshadeLayerActivity extends AppCompatActivity {
mapboxMap = map;
RasterDemSource rasterDemSource = new RasterDemSource(SOURCE_ID, SOURCE_URL);
- mapboxMap.addSource(rasterDemSource);
+ mapboxMap.getStyle().addSource(rasterDemSource);
HillshadeLayer hillshadeLayer = new HillshadeLayer(LAYER_ID, SOURCE_ID);
- mapboxMap.addLayerBelow(hillshadeLayer, LAYER_BELOW_ID);
+ mapboxMap.getStyle().addLayerBelow(hillshadeLayer, LAYER_BELOW_ID);
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
index b9f1dfe810..301dbefa35 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RealTimeGeoJsonActivity.java
@@ -53,7 +53,7 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR
// add source
try {
- mapboxMap.addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URL(URL_GEOJSON_SOURCE)));
+ mapboxMap.getStyle().addSource(new GeoJsonSource(ID_GEOJSON_SOURCE, new URL(URL_GEOJSON_SOURCE)));
} catch (MalformedURLException malformedUrlException) {
Timber.e(malformedUrlException, "Invalid URL");
}
@@ -61,7 +61,7 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR
// add layer
SymbolLayer layer = new SymbolLayer(ID_GEOJSON_LAYER, ID_GEOJSON_SOURCE);
layer.setProperties(iconImage("rocket-15"));
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// loop refresh geojson
handler = new Handler();
@@ -118,7 +118,7 @@ public class RealTimeGeoJsonActivity extends AppCompatActivity implements OnMapR
@Override
public void run() {
- ((GeoJsonSource) mapboxMap.getSource(ID_GEOJSON_SOURCE)).setUrl(URL_GEOJSON_SOURCE);
+ ((GeoJsonSource) mapboxMap.getStyle().getSource(ID_GEOJSON_SOURCE)).setUrl(URL_GEOJSON_SOURCE);
handler.postDelayed(this, 2000);
}
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
index e3010c871b..8d5228113e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleActivity.java
@@ -206,7 +206,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
private void listLayers() {
- List<Layer> layers = mapboxMap.getLayers();
+ List<Layer> layers = mapboxMap.getStyle().getLayers();
StringBuilder builder = new StringBuilder("Layers:");
for (Layer layer : layers) {
builder.append("\n");
@@ -216,7 +216,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
private void listSources() {
- List<Source> sources = mapboxMap.getSources();
+ List<Source> sources = mapboxMap.getStyle().getSources();
StringBuilder builder = new StringBuilder("Sources:");
for (Source source : sources) {
builder.append("\n");
@@ -228,7 +228,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void setLayerInvisible() {
String[] roadLayers = new String[] {"water"};
for (String roadLayer : roadLayers) {
- Layer layer = mapboxMap.getLayer(roadLayer);
+ Layer layer = mapboxMap.getStyle().getLayer(roadLayer);
if (layer != null) {
layer.setProperties(visibility(NONE));
}
@@ -242,7 +242,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
public void onFinish() {
String[] roadLayers = new String[] {"road-label-small", "road-label-medium", "road-label-large"};
for (String roadLayer : roadLayers) {
- Layer layer = mapboxMap.getLayer(roadLayer);
+ Layer layer = mapboxMap.getStyle().getLayer(roadLayer);
if (layer != null) {
layer.setProperties(symbolPlacement(SYMBOL_PLACEMENT_POINT));
}
@@ -252,14 +252,14 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
private void setBackgroundOpacity() {
- Layer background = mapboxMap.getLayer("background");
+ Layer background = mapboxMap.getStyle().getLayer("background");
if (background != null) {
background.setProperties(backgroundOpacity(0.2f));
}
}
private void setWaterColor() {
- FillLayer water = mapboxMap.getLayerAs("water");
+ FillLayer water = mapboxMap.getStyle().getLayerAs("water");
if (water != null) {
water.setFillColorTransition(new TransitionOptions(7500, 1000));
water.setProperties(
@@ -273,7 +273,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void removeBuildings() {
// Zoom to see buildings first
- mapboxMap.removeLayer("building");
+ mapboxMap.getStyle().removeLayer("building");
}
private void addParksLayer() {
@@ -289,7 +289,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
return;
}
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
FillLayer layer = new FillLayer("parksLayer", "amsterdam-spots");
layer.setProperties(
@@ -302,14 +302,14 @@ public class RuntimeStyleActivity extends AppCompatActivity {
// Only show me parks (except westerpark with stroke-width == 3)
layer.setFilter(all(eq(get("type"), literal("park")), eq(get("stroke-width"), literal(3))));
- mapboxMap.addLayerBelow(layer, "building");
+ mapboxMap.getStyle().addLayerBelow(layer, "building");
// layer.setPaintProperty(fillColor(Color.RED)); // XXX But not after the object is attached
// Or get the object later and set it. It's all good.
- mapboxMap.getLayer("parksLayer").setProperties(fillColor(Color.RED));
+ mapboxMap.getStyle().getLayer("parksLayer").setProperties(fillColor(Color.RED));
// You can get a typed layer, if you're sure it's of that type. Use with care
- layer = mapboxMap.getLayerAs("parksLayer");
+ layer = mapboxMap.getStyle().getLayerAs("parksLayer");
// And get some properties
PropertyValue<Boolean> fillAntialias = layer.getFillAntialias();
Timber.d("Fill anti alias: %s", fillAntialias.getValue());
@@ -339,7 +339,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
// Add an empty source
- mapboxMap.addSource(new GeoJsonSource("dynamic-park-source"));
+ mapboxMap.getStyle().addSource(new GeoJsonSource("dynamic-park-source"));
FillLayer layer = new FillLayer("dynamic-parks-layer", "dynamic-park-source");
layer.setProperties(
@@ -352,7 +352,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
// Only show me parks
layer.setFilter(all(eq(get("type"), literal("park"))));
- mapboxMap.addLayer(layer);
+ mapboxMap.getStyle().addLayer(layer);
// Get a good look at it all
mapboxMap.animateCamera(CameraUpdateFactory.zoomTo(12));
@@ -372,7 +372,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
// change the source
int park = counter < parks.features().size() - 1 ? counter : 0;
- GeoJsonSource source = mapboxMap.getSourceAs("dynamic-park-source");
+ GeoJsonSource source = mapboxMap.getStyle().getSourceAs("dynamic-park-source");
if (source == null) {
Timber.e("Source not found");
@@ -392,7 +392,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void addTerrainLayer() {
// Add a source
Source source = new VectorSource("my-terrain-source", "mapbox://mapbox.mapbox-terrain-v2");
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
LineLayer layer = new LineLayer("terrainLayer", "my-terrain-source");
layer.setSourceLayer("contour");
@@ -404,7 +404,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
);
// adding layers below "road" layers
- List<Layer> layers = mapboxMap.getLayers();
+ List<Layer> layers = mapboxMap.getStyle().getLayers();
Layer latestLayer = null;
Collections.reverse(layers);
for (Layer currentLayer : layers) {
@@ -420,17 +420,17 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
if (latestLayer != null) {
- mapboxMap.addLayerBelow(layer, latestLayer.getId());
+ mapboxMap.getStyle().addLayerBelow(layer, latestLayer.getId());
}
// Need to get a fresh handle
- layer = mapboxMap.getLayerAs("terrainLayer");
+ layer = mapboxMap.getStyle().getLayerAs("terrainLayer");
// Make sure it's also applied after the fact
layer.setMinZoom(10);
layer.setMaxZoom(15);
- layer = (LineLayer) mapboxMap.getLayer("terrainLayer");
+ layer = (LineLayer) mapboxMap.getStyle().getLayer("terrainLayer");
Toast.makeText(this, String.format(
"Set min/max zoom to %s - %s", layer.getMinZoom(), layer.getMaxZoom()), Toast.LENGTH_SHORT).show();
}
@@ -438,14 +438,14 @@ public class RuntimeStyleActivity extends AppCompatActivity {
private void addSatelliteLayer() {
// Add a source
Source source = new RasterSource("my-raster-source", "mapbox://mapbox.satellite", 512);
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// Add a layer
- mapboxMap.addLayer(new RasterLayer("satellite-layer", "my-raster-source"));
+ mapboxMap.getStyle().addLayer(new RasterLayer("satellite-layer", "my-raster-source"));
}
private void updateWaterColorOnZoom() {
- FillLayer layer = mapboxMap.getLayerAs("water");
+ FillLayer layer = mapboxMap.getStyle().getLayerAs("water");
if (layer == null) {
return;
}
@@ -474,7 +474,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
tileSet.setMinZoom(0);
tileSet.setMaxZoom(14);
Source source = new VectorSource("custom-tile-source", tileSet);
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// Add a layer
LineLayer lineLayer = new LineLayer("custom-tile-layers", "custom-tile-source");
@@ -486,7 +486,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
lineWidth(2.0f),
lineColor(Color.GREEN)
);
- mapboxMap.addLayer(lineLayer);
+ mapboxMap.getStyle().addLayer(lineLayer);
}
private void styleFillFilterLayer() {
@@ -501,7 +501,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
Timber.d("Styling filtered fill layer");
- FillLayer states = (FillLayer) mapboxMap.getLayer("states");
+ FillLayer states = (FillLayer) mapboxMap.getStyle().getLayer("states");
if (states != null) {
states.setFilter(eq(get("name"), literal("Texas")));
@@ -529,7 +529,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
Timber.d("Styling filtered line layer");
- LineLayer counties = (LineLayer) mapboxMap.getLayer("counties");
+ LineLayer counties = (LineLayer) mapboxMap.getStyle().getLayer("counties");
if (counties != null) {
counties.setFilter(eq(get("NAME10"), "Washington"));
@@ -557,7 +557,7 @@ public class RuntimeStyleActivity extends AppCompatActivity {
Timber.d("Styling numeric fill layer");
- FillLayer regions = (FillLayer) mapboxMap.getLayer("regions");
+ FillLayer regions = (FillLayer) mapboxMap.getStyle().getLayer("regions");
if (regions != null) {
regions.setFilter(all(
@@ -576,10 +576,10 @@ public class RuntimeStyleActivity extends AppCompatActivity {
}
private void bringWaterToFront() {
- Layer water = mapboxMap.getLayer("water");
+ Layer water = mapboxMap.getStyle().getLayer("water");
if (water != null) {
- mapboxMap.removeLayer(water);
- mapboxMap.addLayerAt(water, mapboxMap.getLayers().size() - 1);
+ mapboxMap.getStyle().removeLayer(water);
+ mapboxMap.getStyle().addLayerAt(water, mapboxMap.getStyle().getLayers().size() - 1);
} else {
Toast.makeText(this, "No water layer in this style", Toast.LENGTH_SHORT).show();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
index e51a7ec8a0..59703b3fb1 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/RuntimeStyleTimingTestActivity.java
@@ -34,7 +34,7 @@ public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
mapView.getMapAsync(mapboxMap -> {
RuntimeStyleTimingTestActivity.this.mapboxMap = mapboxMap;
VectorSource museums = new VectorSource("museums_source", "mapbox://mapbox.2opop9hr");
- mapboxMap.addSource(museums);
+ mapboxMap.getStyle().addSource(museums);
CircleLayer museumsLayer = new CircleLayer("museums", "museums_source");
museumsLayer.setSourceLayer("museum-cusco");
@@ -44,7 +44,7 @@ public class RuntimeStyleTimingTestActivity extends AppCompatActivity {
circleColor(Color.argb(1, 55, 148, 179))
);
- mapboxMap.addLayer(museumsLayer);
+ mapboxMap.getStyle().addLayer(museumsLayer);
});
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java
index 5d5c012101..c6c512a473 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolGeneratorActivity.java
@@ -119,11 +119,11 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.menu_action_icon_overlap) {
- SymbolLayer layer = mapboxMap.getLayerAs(LAYER_ID);
+ SymbolLayer layer = mapboxMap.getStyle().getLayerAs(LAYER_ID);
layer.setProperties(iconAllowOverlap(!layer.getIconAllowOverlap().getValue()));
return true;
} else if (item.getItemId() == R.id.menu_action_filter) {
- SymbolLayer layer = mapboxMap.getLayerAs(LAYER_ID);
+ SymbolLayer layer = mapboxMap.getStyle().getLayerAs(LAYER_ID);
layer.setFilter(eq(get(FEATURE_RANK), literal(1)));
Timber.e("Filter that was set: %s", layer.getFilter());
return true;
@@ -286,10 +286,10 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
// add a geojson source to the map
Source source = new GeoJsonSource(SOURCE_ID, featureCollection);
- mapboxMap.addSource(source);
+ mapboxMap.getStyle().addSource(source);
// add symbol layer
- mapboxMap.addLayer(symbolLayer);
+ mapboxMap.getStyle().addLayer(symbolLayer);
// get expressions
Expression iconImageExpressionResult = symbolLayer.getIconImage().getExpression();
@@ -350,7 +350,7 @@ public class SymbolGeneratorActivity extends AppCompatActivity implements OnMapR
@Override
protected void onPostExecute(HashMap<String, Bitmap> bitmapHashMap) {
super.onPostExecute(bitmapHashMap);
- mapboxMap.addImages(bitmapHashMap);
+ mapboxMap.getStyle().addImages(bitmapHashMap);
}
}
} \ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
index d261b1f227..daf651807e 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/SymbolLayerActivity.java
@@ -101,7 +101,7 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
// Add a sdf image for the makers
Drawable icLayersDrawable = getResources().getDrawable(R.drawable.ic_layers);
Bitmap icLayersBitmap = BitmapUtils.getBitmapFromDrawable(icLayersDrawable);
- mapboxMap.addImage(
+ mapboxMap.getStyle().addImage(
MARKER_ICON,
icLayersBitmap,
true
@@ -112,10 +112,10 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
Feature.fromGeometry(Point.fromLngLat(4.91638, 52.35673), featureProperties("Marker 1")),
Feature.fromGeometry(Point.fromLngLat(4.91638, 52.34673), featureProperties("Marker 2"))
});
- mapboxMap.addSource(geoJsonSource = new GeoJsonSource(MARKER_SOURCE, markerCollection));
+ mapboxMap.getStyle().addSource(geoJsonSource = new GeoJsonSource(MARKER_SOURCE, markerCollection));
// Add the symbol-layer
- mapboxMap.addLayer(
+ mapboxMap.getStyle().addLayer(
new SymbolLayer(MARKER_LAYER, MARKER_SOURCE)
.withProperties(
iconImage(MARKER_ICON),
@@ -167,17 +167,17 @@ public class SymbolLayerActivity extends AppCompatActivity implements MapboxMap.
}
private void toggleTextSize() {
- SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER);
+ SymbolLayer layer = mapboxMap.getStyle().getLayerAs(MARKER_LAYER);
layer.setProperties(layer.getTextSize().getValue() > 10 ? textSize(10f) : textSize(20f));
}
private void toggleTextField() {
- SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER);
+ SymbolLayer layer = mapboxMap.getStyle().getLayerAs(MARKER_LAYER);
layer.setProperties("{title}".equals(layer.getTextField().getValue()) ? textField("āA") : textField("{title}"));
}
private void toggleTextFont() {
- SymbolLayer layer = mapboxMap.getLayerAs(MARKER_LAYER);
+ SymbolLayer layer = mapboxMap.getStyle().getLayerAs(MARKER_LAYER);
if (initialFont) {
layer.setProperties(textFont(new String[] {"DIN Offc Pro Bold", "Arial Unicode MS Bold"}));
} else {
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
index 32535a27d1..27a89dd660 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/style/ZoomFunctionSymbolLayerActivity.java
@@ -13,6 +13,7 @@ import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
+import com.mapbox.mapboxsdk.maps.Style;
import com.mapbox.mapboxsdk.style.layers.Property;
import com.mapbox.mapboxsdk.style.layers.SymbolLayer;
import com.mapbox.mapboxsdk.style.sources.GeoJsonSource;
@@ -62,7 +63,7 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
Feature feature = featureList.get(0);
boolean selectedNow = feature.getBooleanProperty(KEY_PROPERTY_SELECTED);
isSelected = !selectedNow;
- updateSource();
+ updateSource(mapboxMap.getStyle());
} else {
Timber.e("No features found");
}
@@ -79,19 +80,20 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(map -> {
mapboxMap = map;
- updateSource();
- addLayer();
+ Style style = map.getStyle();
+ updateSource(style);
+ addLayer(style);
map.addOnMapClickListener(mapClickListener);
});
}
- private void updateSource() {
+ private void updateSource(Style style) {
FeatureCollection featureCollection = createFeatureCollection();
if (source != null) {
source.setGeoJson(featureCollection);
} else {
source = new GeoJsonSource(SOURCE_ID, featureCollection);
- mapboxMap.addSource(source);
+ style.addSource(source);
}
}
@@ -113,7 +115,7 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
return FeatureCollection.fromFeatures(new Feature[] {feature});
}
- private void addLayer() {
+ private void addLayer(Style style) {
layer = new SymbolLayer(LAYER_ID, SOURCE_ID);
layer.setProperties(
iconImage(
@@ -129,7 +131,7 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
),
iconAllowOverlap(true)
);
- mapboxMap.addLayer(layer);
+ style.addLayer(layer);
}
@Override
@@ -143,7 +145,7 @@ public class ZoomFunctionSymbolLayerActivity extends AppCompatActivity {
if (mapboxMap != null) {
if (item.getItemId() == R.id.menu_action_change_location) {
isInitialPosition = !isInitialPosition;
- updateSource();
+ updateSource(mapboxMap.getStyle());
} else if (item.getItemId() == R.id.menu_action_toggle_source) {
toggleSymbolLayerVisibility();
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
index b47ed6cc41..faa04c2e9b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/activity/textureview/TextureViewDebugModeActivity.java
@@ -86,7 +86,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
mapView.addOnDidFinishLoadingStyleListener(() -> {
if (mapboxMap != null) {
- setupNavigationView(mapboxMap.getLayers());
+ setupNavigationView(mapboxMap.getStyle().getLayers());
}
});
@@ -100,7 +100,7 @@ public class TextureViewDebugModeActivity extends AppCompatActivity implements O
public void onMapReady(@NonNull MapboxMap map) {
mapboxMap = map;
- setupNavigationView(mapboxMap.getLayers());
+ setupNavigationView(mapboxMap.getStyle().getLayers());
setupZoomView();
setFpsView();
}