[android] - move all layer, source, image, light and transition configurations to style.java
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
//
|
||||
@@ -543,20 +320,6 @@ public final class MapboxMap {
|
||||
return projection;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
@@ -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,11 +181,111 @@ 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);
|
||||
}
|
||||
|
||||
//
|
||||
// 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>
|
||||
* Set the transition duration for style changes.
|
||||
@@ -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
|
||||
//
|
||||
|
||||
/**
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user