[android] source list accessor + example

This commit is contained in:
Ivo van Dongen
2017-02-24 16:15:00 +02:00
committed by Ivo van Dongen
parent ec1dc2622b
commit f0de56cffa
7 changed files with 81 additions and 0 deletions

View File

@@ -291,6 +291,22 @@ public final class MapboxMap {
nativeMapView.removeLayer(layer);
}
/**
* Retrieve all the sources in the style
*
* @return all the sources in the current style
*/
@UiThread
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
@UiThread
public Source getSource(@NonNull String sourceId) {

View File

@@ -782,6 +782,13 @@ final class NativeMapView {
nativeRemoveLayer(layer.getNativePtr());
}
public List<Source> getSources() {
if (isDestroyedOn("getSources")) {
return null;
}
return Arrays.asList(nativeGetSources());
}
public Source getSource(@NonNull String sourceId) {
if (isDestroyedOn("getSource")) {
return null;
@@ -1071,6 +1078,8 @@ final class NativeMapView {
private native void nativeRemoveLayer(long layerId);
private native Source[] nativeGetSources();
private native Source nativeGetSource(String sourceId);
private native void nativeAddSource(long nativeSourcePtr) throws CannotAddSourceException;