summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Hallahan <nick@theoutpost.io>2015-07-16 10:08:02 -0700
committerNicholas Hallahan <nick@theoutpost.io>2015-07-16 10:08:02 -0700
commitaebd4196ac345a1eb49f0c9e2f8ec2215cad4ad7 (patch)
treea859fd6aed046412a109bd94029f1ed691561172
parenta203538886f7bfae4fb274536cfd035c40b5c46a (diff)
downloadqtlocation-mapboxgl-aebd4196ac345a1eb49f0c9e2f8ec2215cad4ad7.tar.gz
attempting to make ShapeAnnotation with segment and properties #1716
-rw-r--r--android/cpp/jni.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp
index 9049c85667..fcf53ad0c9 100644
--- a/android/cpp/jni.cpp
+++ b/android/cpp/jni.cpp
@@ -17,6 +17,7 @@
#include <mbgl/android/native_map_view.hpp>
#include <mbgl/map/map.hpp>
#include <mbgl/annotation/point_annotation.hpp>
+#include <mbgl/annotation/shape_annotation.hpp>
#include <mbgl/platform/event.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/storage/network_status.hpp>
@@ -466,7 +467,7 @@ jlong JNICALL nativeAddMarker(JNIEnv *env, jobject obj, jlong nativeMapViewPtr,
jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject polyline) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddPolyline");
assert(nativeMapViewPtr != 0);
- // NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
+ NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
// ***** Java fields ***** //
// float alpha;
@@ -480,7 +481,6 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
env->ExceptionDescribe();
return -1;
}
- ++alpha;
jboolean visible = env->GetBooleanField(polyline, polylineVisibleId);
if (env->ExceptionCheck()) {
@@ -502,6 +502,14 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
return -1;
}
+ mbgl::StyleProperties shapeProperties;
+ mbgl::LineProperties lineProperties;
+ lineProperties.opacity = alpha;
+ lineProperties.color = {{ 0.3, 0.7, 0.1, 1 }};;
+ lineProperties.width = width;
+ shapeProperties.set<mbgl::LineProperties>(lineProperties);
+
+
jobject points = env->GetObjectField(polyline, polylinePointsId);
if (points == nullptr) {
if (env->ThrowNew(nullPointerExceptionClass, "List cannot be null.") < 0) {
@@ -524,6 +532,9 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
return -1;
}
+ mbgl::AnnotationSegment segment;
+ segment.reserve(len);
+
for (jsize i = 0; i < len; i++) {
jobject latLng = reinterpret_cast<jobject>(env->GetObjectArrayElement(array, i));
if (latLng == nullptr) {
@@ -536,16 +547,19 @@ jlong JNICALL nativeAddPolyline(JNIEnv *env, jobject obj, jlong nativeMapViewPtr
env->ExceptionDescribe();
return -1;
}
- latitude++;
+
jdouble longitude = env->GetDoubleField(latLng, latLngLongitudeId);
if (env->ExceptionCheck()) {
env->ExceptionDescribe();
return -1;
}
- longitude++;
+
+ segment.push_back(mbgl::LatLng(latitude, longitude));
}
- return (jlong)width;
+
+
+ return (jlong) nativeMapView->getMap().addShapeAnnotation(mbgl::ShapeAnnotation(segment, shapeProperties));
}
void JNICALL nativeRemoveAnnotation(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jlong annotationId) {