summaryrefslogtreecommitdiff
path: root/android/cpp/jni.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'android/cpp/jni.cpp')
-rw-r--r--android/cpp/jni.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/android/cpp/jni.cpp b/android/cpp/jni.cpp
index 64e72e1499..bfa07a2ffb 100644
--- a/android/cpp/jni.cpp
+++ b/android/cpp/jni.cpp
@@ -419,6 +419,26 @@ void JNICALL nativeSetLatLng(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, j
nativeMapView->getMap().setLatLng(mbgl::LatLng(latitude, longitude), std::chrono::milliseconds(duration));
}
+void JNICALL nativeAddAnnotation(JNIEnv *env, jobject obj, jlong nativeMapViewPtr, jobject latLng) {
+ mbgl::Log::Debug(mbgl::Event::JNI, "nativeAddAnnotation");
+ assert(nativeMapViewPtr != 0);
+ NativeMapView *nativeMapView = reinterpret_cast<NativeMapView *>(nativeMapViewPtr);
+
+ jdouble latitude = env->GetDoubleField(latLng, latLngLatitudeId);
+ if (env->ExceptionCheck()) {
+ env->ExceptionDescribe();
+ return;
+ }
+
+ jdouble longitude = env->GetDoubleField(latLng, latLngLongitudeId);
+ if (env->ExceptionCheck()) {
+ env->ExceptionDescribe();
+ return;
+ }
+
+ nativeMapView->getMap().addPointAnnotation(mbgl::LatLng(latitude, longitude), std::string(""));
+}
+
jobject JNICALL nativeGetLatLng(JNIEnv *env, jobject obj, jlong nativeMapViewPtr) {
mbgl::Log::Debug(mbgl::Event::JNI, "nativeGetLatLng");
assert(nativeMapViewPtr != 0);
@@ -952,6 +972,8 @@ extern "C" JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
{"nativeMoveBy", "(JDDJ)V", reinterpret_cast<void *>(&nativeMoveBy)},
{"nativeSetLatLng", "(JLcom/mapbox/mapboxgl/geometry/LatLng;J)V",
reinterpret_cast<void *>(&nativeSetLatLng)},
+ {"nativeAddAnnotation", "(JLcom/mapbox/mapboxgl/geometry/LatLng;)V",
+ reinterpret_cast<void *>(&nativeAddAnnotation)},
{"nativeGetLatLng", "(J)Lcom/mapbox/mapboxgl/geometry/LatLng;",
reinterpret_cast<void *>(&nativeGetLatLng)},
{"nativeResetPosition", "(J)V", reinterpret_cast<void *>(&nativeResetPosition)},