summaryrefslogtreecommitdiff
path: root/platform/android/src
diff options
context:
space:
mode:
Diffstat (limited to 'platform/android/src')
-rwxr-xr-xplatform/android/src/native_map_view.cpp32
-rwxr-xr-xplatform/android/src/native_map_view.hpp10
2 files changed, 16 insertions, 26 deletions
diff --git a/platform/android/src/native_map_view.cpp b/platform/android/src/native_map_view.cpp
index 1c744a6b57..d908b14d36 100755
--- a/platform/android/src/native_map_view.cpp
+++ b/platform/android/src/native_map_view.cpp
@@ -824,50 +824,42 @@ void NativeMapView::addLayerAt(JNIEnv& env, jlong nativeLayerPtr, jni::jint inde
}
}
-/**
- * Remove by layer id.
- */
-jni::Local<jni::Object<Layer>> NativeMapView::removeLayerById(JNIEnv& env, const jni::String& id) {
- std::unique_ptr<mbgl::style::Layer> coreLayer = map->getStyle().removeLayer(jni::Make<std::string>(env, id));
- if (coreLayer) {
- return LayerManagerAndroid::get()->createJavaLayerPeer(env, *map, std::move(coreLayer));
- } else {
- return jni::Local<jni::Object<Layer>>();
- }
-}
/**
* Remove layer at index.
*/
-jni::Local<jni::Object<Layer>> NativeMapView::removeLayerAt(JNIEnv& env, jni::jint index) {
+jni::jboolean NativeMapView::removeLayerAt(JNIEnv& env, jni::jint index) {
auto layers = map->getStyle().getLayers();
// Check index
int numLayers = layers.size() - 1;
if (index > numLayers || index < 0) {
Log::Warning(Event::JNI, "Index out of range: %i", index);
- return jni::Local<jni::Object<Layer>>();
+ return jni::jni_false;
}
std::unique_ptr<mbgl::style::Layer> coreLayer = map->getStyle().removeLayer(layers.at(index)->getID());
if (coreLayer) {
- return LayerManagerAndroid::get()->createJavaLayerPeer(env, *map, std::move(coreLayer));
- } else {
- return jni::Local<jni::Object<Layer>>();
+ jni::Local<jni::Object<Layer>> layerObj =
+ LayerManagerAndroid::get()->createJavaLayerPeer(env, *map, std::move(coreLayer));
+ return jni::jni_true;
}
+ return jni::jni_false;
}
/**
* Remove with wrapper object id. Ownership is transferred back to the wrapper
*/
-void NativeMapView::removeLayer(JNIEnv&, jlong layerPtr) {
+jni::jboolean NativeMapView::removeLayer(JNIEnv&, jlong layerPtr) {
assert(layerPtr != 0);
mbgl::android::Layer *layer = reinterpret_cast<mbgl::android::Layer *>(layerPtr);
std::unique_ptr<mbgl::style::Layer> coreLayer = map->getStyle().removeLayer(layer->get().getID());
if (coreLayer) {
layer->setLayer(std::move(coreLayer));
+ return jni::jni_true;
}
+ return jni::jni_false;
}
jni::Local<jni::Array<jni::Object<Source>>> NativeMapView::getSources(JNIEnv& env) {
@@ -908,13 +900,16 @@ void NativeMapView::addSource(JNIEnv& env, const jni::Object<Source>& obj, jlong
}
}
-void NativeMapView::removeSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
+jni::jboolean NativeMapView::removeSource(JNIEnv& env, const jni::Object<Source>& obj, jlong sourcePtr) {
assert(sourcePtr != 0);
mbgl::android::Source *source = reinterpret_cast<mbgl::android::Source *>(sourcePtr);
if (source->removeFromMap(env, obj, *map)) {
source->releaseJavaPeer();
+ return jni::jni_true;
}
+
+ return jni::jni_false;
}
void NativeMapView::addImage(JNIEnv& env, const jni::String& name, const jni::Object<Bitmap>& bitmap, jni::jfloat scale, jni::jboolean sdf) {
@@ -1046,7 +1041,6 @@ void NativeMapView::registerNative(jni::JNIEnv& env) {
METHOD(&NativeMapView::addLayer, "nativeAddLayer"),
METHOD(&NativeMapView::addLayerAbove, "nativeAddLayerAbove"),
METHOD(&NativeMapView::addLayerAt, "nativeAddLayerAt"),
- METHOD(&NativeMapView::removeLayerById, "nativeRemoveLayerById"),
METHOD(&NativeMapView::removeLayerAt, "nativeRemoveLayerAt"),
METHOD(&NativeMapView::removeLayer, "nativeRemoveLayer"),
METHOD(&NativeMapView::getSources, "nativeGetSources"),
diff --git a/platform/android/src/native_map_view.hpp b/platform/android/src/native_map_view.hpp
index 704331d8e2..57676d3edf 100755
--- a/platform/android/src/native_map_view.hpp
+++ b/platform/android/src/native_map_view.hpp
@@ -216,11 +216,9 @@ public:
void addLayerAt(JNIEnv&, jni::jlong, jni::jint);
- jni::Local<jni::Object<Layer>> removeLayerById(JNIEnv&, const jni::String&);
+ jni::jboolean removeLayerAt(JNIEnv&, jni::jint);
- jni::Local<jni::Object<Layer>> removeLayerAt(JNIEnv&, jni::jint);
-
- void removeLayer(JNIEnv&, jlong);
+ jni::jboolean removeLayer(JNIEnv&, jlong);
jni::Local<jni::Array<jni::Object<Source>>> getSources(JNIEnv&);
@@ -228,9 +226,7 @@ public:
void addSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);
- jni::Local<jni::Object<Source>> removeSourceById(JNIEnv&, const jni::String&);
-
- void removeSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);
+ jni::jboolean removeSource(JNIEnv&, const jni::Object<Source>&, jlong nativePtr);
void addImage(JNIEnv&, const jni::String&, const jni::Object<Bitmap>& bitmap, jni::jfloat, jni::jboolean);