diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-09-03 15:43:12 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-09-04 15:16:18 +0200 |
commit | 42aaf3e346c583cbfd68e0f379a705a41af5238f (patch) | |
tree | f2fc2938f6385fed8756fa1ba6d9c0983784c71b /platform/android/src | |
parent | 18b43f29cfd7d2a4b316854e910ddf8adaf00fcb (diff) | |
download | qtlocation-mapboxgl-42aaf3e346c583cbfd68e0f379a705a41af5238f.tar.gz |
[android] - add get source id to supported layer types
Diffstat (limited to 'platform/android/src')
-rw-r--r-- | platform/android/src/style/layers/layer.cpp | 22 | ||||
-rw-r--r-- | platform/android/src/style/layers/layer.hpp | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/platform/android/src/style/layers/layer.cpp b/platform/android/src/style/layers/layer.cpp index 6c08893411..48e09674e8 100644 --- a/platform/android/src/style/layers/layer.cpp +++ b/platform/android/src/style/layers/layer.cpp @@ -25,6 +25,8 @@ // C++ -> Java conversion #include "../conversion/property_value.hpp" +#include "custom_layer.hpp" +#include "background_layer.hpp" #include <mbgl/style/filter.hpp> #include <string> @@ -204,6 +206,25 @@ namespace android { return jni::Make<jni::String>(env, layer.accept(GetSourceLayerEvaluator())); } + struct GetSourceIdEvaluator { + std::string noop(std::string layerType) { + Log::Warning(mbgl::Event::JNI, "%s doesn't support get source id", layerType.c_str()); + return {}; + } + + std::string operator()(style::BackgroundLayer&) { return noop("BackgroundLayer"); } + std::string operator()(style::CustomLayer&) { return noop("CustomLayer"); } + + template <class LayerType> + std::string operator()(LayerType& layer) { + return layer.getSourceID(); + } + }; + + jni::String Layer::getSourceId(jni::JNIEnv& env) { + return jni::Make<jni::String>(env, layer.accept(GetSourceIdEvaluator())); + } + jni::jfloat Layer::getMinZoom(jni::JNIEnv&){ return layer.getMinZoom(); } @@ -242,6 +263,7 @@ namespace android { METHOD(&Layer::getFilter, "nativeGetFilter"), METHOD(&Layer::setSourceLayer, "nativeSetSourceLayer"), METHOD(&Layer::getSourceLayer, "nativeGetSourceLayer"), + METHOD(&Layer::getSourceId, "nativeGetSourceId"), METHOD(&Layer::getMinZoom, "nativeGetMinZoom"), METHOD(&Layer::getMaxZoom, "nativeGetMaxZoom"), METHOD(&Layer::setMinZoom, "nativeSetMinZoom"), diff --git a/platform/android/src/style/layers/layer.hpp b/platform/android/src/style/layers/layer.hpp index 2486b0dfa6..41022bf74a 100644 --- a/platform/android/src/style/layers/layer.hpp +++ b/platform/android/src/style/layers/layer.hpp @@ -49,6 +49,8 @@ public: jni::String getId(jni::JNIEnv&); + jni::String getSourceId(jni::JNIEnv&); + style::Layer& get(); void setLayoutProperty(jni::JNIEnv&, jni::String, jni::Object<> value); |