[android] layer list accessor + example

This commit is contained in:
Ivo van Dongen
2017-02-24 14:29:57 +02:00
committed by Ivo van Dongen
parent 62e85c1224
commit ec1dc2622b
7 changed files with 88 additions and 0 deletions

View File

@@ -209,6 +209,22 @@ public final class MapboxMap {
nativeMapView.setTransitionDelay(delay);
}
/**
* Retrieve all the layers in the style
*
* @return all the layers in the current style
*/
@UiThread
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
@UiThread
public Layer getLayer(@NonNull String layerId) {

View File

@@ -747,6 +747,13 @@ final class NativeMapView {
nativeSetTransitionDelay(delay);
}
public List<Layer> getLayers() {
if (isDestroyedOn("getLayers")) {
return null;
}
return Arrays.asList(nativeGetLayers());
}
public Layer getLayer(String layerId) {
if (isDestroyedOn("getLayer")) {
return null;
@@ -1054,6 +1061,8 @@ final class NativeMapView {
private native void nativeSetTransitionDelay(long delay);
private native Layer[] nativeGetLayers();
private native Layer nativeGetLayer(String layerId);
private native void nativeAddLayer(long layerPtr, String before) throws CannotAddLayerException;