[android] return layer ownership on remove

This commit is contained in:
Ivo van Dongen
2016-11-14 10:44:06 +01:00
committed by Ivo van Dongen
parent f66ea0bef9
commit 8d53f9f091
6 changed files with 77 additions and 5 deletions

View File

@@ -155,6 +155,17 @@ public class MapboxMap {
getMapView().getNativeMapView().removeLayer(layerId);
}
/**
* Removes the layer. The reference is re-usable after this and can be re-added
*
* @param layer the layer to remove
* @throws NoSuchLayerException
*/
@UiThread
public void removeLayer(@NonNull Layer layer) throws NoSuchLayerException {
getMapView().getNativeMapView().removeLayer(layer);
}
@Nullable
@UiThread
public Source getSource(@NonNull String sourceId) {

View File

@@ -491,7 +491,11 @@ final class NativeMapView {
}
public void removeLayer(@NonNull String layerId) throws NoSuchLayerException {
nativeRemoveLayer(nativeMapViewPtr, layerId);
nativeRemoveLayerById(nativeMapViewPtr, layerId);
}
public void removeLayer(@NonNull Layer layer) throws NoSuchLayerException {
nativeRemoveLayer(nativeMapViewPtr, layer.getNativePtr());
}
public Source getSource(@NonNull String sourceId) {
@@ -743,7 +747,9 @@ final class NativeMapView {
private native void nativeAddLayer(long nativeMapViewPtr, long layerPtr, String before);
private native void nativeRemoveLayer(long nativeMapViewPtr, String layerId) throws NoSuchLayerException;
private native void nativeRemoveLayerById(long nativeMapViewPtr, String layerId) throws NoSuchLayerException;
private native void nativeRemoveLayer(long nativeMapViewPtr, long layerId) throws NoSuchLayerException;
private native Source nativeGetSource(long nativeMapViewPtr, String sourceId);