diff options
author | Ivo van Dongen <info@ivovandongen.nl> | 2017-02-27 20:12:42 +0200 |
---|---|---|
committer | Ivo van Dongen <ivovandongen@users.noreply.github.com> | 2017-02-28 09:33:04 -0800 |
commit | 99786e1e3ff1cb79f6befe93e02c968e5e6b6781 (patch) | |
tree | 8a28a4e1b468f211eb535d9a2853c96f165df19d /platform/android/MapboxGLAndroidSDK | |
parent | a9d2929819a5b4268a83e8ccd90eeb0b1f1e2f72 (diff) | |
download | qtlocation-mapboxgl-99786e1e3ff1cb79f6befe93e02c968e5e6b6781.tar.gz |
[android] insert layer at index
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK')
2 files changed, 21 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java index 3623872a4f..e3e33ec067 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/MapboxMap.java @@ -284,6 +284,18 @@ public final class MapboxMap { } /** + * 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 + */ + @UiThread + public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) { + nativeMapView.addLayerAt(layer, index); + } + + /** * Removes the layer. Any references to the layer become invalid and should not be used anymore * * @param layerId the layer to remove diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java index 67a0c45134..914dbad32d 100755 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/maps/NativeMapView.java @@ -783,6 +783,13 @@ final class NativeMapView { nativeAddLayerAbove(layer.getNativePtr(), above); } + public void addLayerAt(@NonNull Layer layer, @IntRange(from = 0) int index) { + if (isDestroyedOn("addLayerAt")) { + return; + } + nativeAddLayerAt(layer.getNativePtr(), index); + } + @Nullable public Layer removeLayer(@NonNull String layerId) { if (isDestroyedOn("removeLayer")) { @@ -1104,6 +1111,8 @@ final class NativeMapView { private native void nativeAddLayerAbove(long layerPtr, String above) throws CannotAddLayerException; + private native void nativeAddLayerAt(long layerPtr, int index) throws CannotAddLayerException; + private native Layer nativeRemoveLayerById(String layerId); private native void nativeRemoveLayer(long layerId); |