[android] source list accessor + example
This commit is contained in:
committed by
Ivo van Dongen
parent
ec1dc2622b
commit
f0de56cffa
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user