summaryrefslogtreecommitdiff
path: root/platform/android/src/style/sources
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-03-23 17:53:59 +0200
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-03-28 15:44:22 +0300
commit02fd38ccbc6a4070162a2b9167d7f8d42b3706a0 (patch)
tree6b2df17761b86055cbda6eea919058f39cf47ebd /platform/android/src/style/sources
parentfa7489fb7ea8ec85cb746e0bc497518d72c638b9 (diff)
downloadqtlocation-mapboxgl-02fd38ccbc6a4070162a2b9167d7f8d42b3706a0.tar.gz
[android] add option to set geometry and feature on geojson source
Diffstat (limited to 'platform/android/src/style/sources')
-rw-r--r--platform/android/src/style/sources/geojson_source.cpp22
-rw-r--r--platform/android/src/style/sources/geojson_source.hpp5
2 files changed, 27 insertions, 0 deletions
diff --git a/platform/android/src/style/sources/geojson_source.cpp b/platform/android/src/style/sources/geojson_source.cpp
index ad55889858..c201cdade1 100644
--- a/platform/android/src/style/sources/geojson_source.cpp
+++ b/platform/android/src/style/sources/geojson_source.cpp
@@ -72,6 +72,26 @@ namespace android {
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setGeoJSON(GeoJSON(features));
}
+ void GeoJSONSource::setFeature(jni::JNIEnv& env, jni::Object<geojson::Feature> jFeature) {
+ using namespace mbgl::android::geojson;
+
+ // Convert the jni object
+ auto feature = Feature::convert(env, jFeature);
+
+ // Update the core source
+ source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setGeoJSON(GeoJSON(feature));
+ }
+
+ void GeoJSONSource::setGeometry(jni::JNIEnv& env, jni::Object<geojson::Geometry> jGeometry) {
+ using namespace mbgl::android::geojson;
+
+ // Convert the jni object
+ auto geometry = Geometry::convert(env, jGeometry);
+
+ // Update the core source
+ source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setGeoJSON(GeoJSON(geometry));
+ }
+
void GeoJSONSource::setURL(jni::JNIEnv& env, jni::String url) {
// Update the core source
source.as<mbgl::style::GeoJSONSource>()->GeoJSONSource::setURL(jni::Make<std::string>(env, url));
@@ -108,6 +128,8 @@ namespace android {
"finalize",
METHOD(&GeoJSONSource::setGeoJSONString, "nativeSetGeoJsonString"),
METHOD(&GeoJSONSource::setFeatureCollection, "nativeSetFeatureCollection"),
+ METHOD(&GeoJSONSource::setFeature, "nativeSetFeature"),
+ METHOD(&GeoJSONSource::setGeometry, "nativeSetGeometry"),
METHOD(&GeoJSONSource::setURL, "nativeSetUrl"),
METHOD(&GeoJSONSource::querySourceFeatures, "querySourceFeatures")
);
diff --git a/platform/android/src/style/sources/geojson_source.hpp b/platform/android/src/style/sources/geojson_source.hpp
index 98d98e26b3..51ea452fb2 100644
--- a/platform/android/src/style/sources/geojson_source.hpp
+++ b/platform/android/src/style/sources/geojson_source.hpp
@@ -2,6 +2,7 @@
#include "source.hpp"
#include <mbgl/style/sources/geojson_source.hpp>
+#include "../../geojson/geometry.hpp"
#include "../../geojson/feature.hpp"
#include "../../geojson/feature_collection.hpp"
#include <jni/jni.hpp>
@@ -28,6 +29,10 @@ public:
void setFeatureCollection(jni::JNIEnv&, jni::Object<geojson::FeatureCollection>);
+ void setFeature(jni::JNIEnv&, jni::Object<geojson::Feature>);
+
+ void setGeometry(jni::JNIEnv&, jni::Object<geojson::Geometry>);
+
void setURL(jni::JNIEnv&, jni::String);
jni::Array<jni::Object<geojson::Feature>> querySourceFeatures(jni::JNIEnv&,