summaryrefslogtreecommitdiff
path: root/platform/android/MapboxGLAndroidSDK
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/MapboxGLAndroidSDK
parentfa7489fb7ea8ec85cb746e0bc497518d72c638b9 (diff)
downloadqtlocation-mapboxgl-02fd38ccbc6a4070162a2b9167d7f8d42b3706a0.tar.gz
[android] add option to set geometry and feature on geojson source
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK')
-rw-r--r--platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java69
1 files changed, 69 insertions, 0 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
index 3c1a325169..718b790df2 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/sources/GeoJsonSource.java
@@ -7,6 +7,7 @@ import android.support.annotation.UiThread;
import com.mapbox.mapboxsdk.style.layers.Filter;
import com.mapbox.services.commons.geojson.Feature;
import com.mapbox.services.commons.geojson.FeatureCollection;
+import com.mapbox.services.commons.geojson.Geometry;
import java.net.URL;
import java.util.ArrayList;
@@ -127,6 +128,70 @@ public class GeoJsonSource extends Source {
}
/**
+ * Create a GeoJsonSource from a {@link Feature}
+ *
+ * @param id the source id
+ * @param feature the feature
+ */
+ public GeoJsonSource(String id, Feature feature) {
+ initialize(id, null);
+ setGeoJson(feature);
+ }
+
+ /**
+ * Create a GeoJsonSource from a {@link Feature} and non-default {@link GeoJsonOptions}
+ *
+ * @param id the source id
+ * @param feature the feature
+ * @param options options
+ */
+ public GeoJsonSource(String id, Feature feature, GeoJsonOptions options) {
+ initialize(id, options);
+ setGeoJson(feature);
+ }
+
+ /**
+ * Create a GeoJsonSource from a {@link Geometry}
+ *
+ * @param id the source id
+ * @param geometry the geometry
+ */
+ public GeoJsonSource(String id, Geometry geometry) {
+ initialize(id, null);
+ setGeoJson(geometry);
+ }
+
+ /**
+ * Create a GeoJsonSource from a {@link Geometry} and non-default {@link GeoJsonOptions}
+ *
+ * @param id the source id
+ * @param geometry the geometry
+ * @param options options
+ */
+ public GeoJsonSource(String id, Geometry geometry, GeoJsonOptions options) {
+ initialize(id, options);
+ setGeoJson(geometry);
+ }
+
+ /**
+ * Updates the GeoJson with a single feature
+ *
+ * @param feature the GeoJSON {@link Feature} to set
+ */
+ public void setGeoJson(Feature feature) {
+ nativeSetFeature(feature);
+ }
+
+ /**
+ * Updates the GeoJson with a single geometry
+ *
+ * @param geometry the GeoJSON {@link Geometry} to set
+ */
+ public void setGeoJson(Geometry<?> geometry) {
+ nativeSetGeometry(geometry);
+ }
+
+ /**
* Updates the GeoJson
*
* @param features the GeoJSON {@link FeatureCollection}
@@ -182,6 +247,10 @@ public class GeoJsonSource extends Source {
private native void nativeSetFeatureCollection(FeatureCollection geoJson);
+ private native void nativeSetFeature(Feature feature);
+
+ private native void nativeSetGeometry(Geometry<?> geometry);
+
private native Feature[] querySourceFeatures(Object[] filter);
@Override