diff options
Diffstat (limited to 'platform/android/src/snapshotter')
-rw-r--r-- | platform/android/src/snapshotter/map_snapshot.cpp | 14 | ||||
-rw-r--r-- | platform/android/src/snapshotter/map_snapshot.hpp | 7 | ||||
-rw-r--r-- | platform/android/src/snapshotter/map_snapshotter.cpp | 4 |
3 files changed, 15 insertions, 10 deletions
diff --git a/platform/android/src/snapshotter/map_snapshot.cpp b/platform/android/src/snapshotter/map_snapshot.cpp index bbbf7cc207..42c1c16ca1 100644 --- a/platform/android/src/snapshotter/map_snapshot.cpp +++ b/platform/android/src/snapshotter/map_snapshot.cpp @@ -8,9 +8,10 @@ namespace mbgl { namespace android { -MapSnapshot::MapSnapshot(float pixelRatio_, MapSnapshot::PointForFn pointForFn_) +MapSnapshot::MapSnapshot(float pixelRatio_, MapSnapshot::PointForFn pointForFn_, MapSnapshot::LatLngForFn latLngForFn_) : pixelRatio(pixelRatio_) - , pointForFn(std::move(pointForFn_)) { + , pointForFn(std::move(pointForFn_)) + , latLngForFn(std::move(latLngForFn_)) { } MapSnapshot::~MapSnapshot() = default; @@ -20,8 +21,8 @@ jni::Object<PointF> MapSnapshot::pixelForLatLng(jni::JNIEnv& env, jni::Object<La return PointF::New(env, point.x * pixelRatio, point.y * pixelRatio); } -jni::Object<LatLng> MapSnapshot::latLngForPixel(jni::JNIEnv& env, jni::Object<PointF>) { - return LatLng::New(env, {0, 0}); +jni::Object<LatLng> MapSnapshot::latLngForPixel(jni::JNIEnv& env, jni::Object<PointF>jPoint) { + return LatLng::New(env, latLngForFn(PointF::getScreenCoordinate(env, jPoint))); } // Static methods // @@ -31,13 +32,14 @@ jni::Object<MapSnapshot> MapSnapshot::New(JNIEnv& env, float pixelRatio, std::vector<std::string> attributions, bool showLogo, - mbgl::MapSnapshotter::PointForFn pointForFn) { + mbgl::MapSnapshotter::PointForFn pointForFn, + mbgl::MapSnapshotter::LatLngForFn latLngForFn) { // Create the bitmap auto bitmap = Bitmap::CreateBitmap(env, std::move(image)); // Create the Mapsnapshot peers static auto constructor = javaClass.GetConstructor<jni::jlong, jni::Object<Bitmap>, jni::Array<jni::String>, jni::jboolean>(env); - auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn); + auto nativePeer = std::make_unique<MapSnapshot>(pixelRatio, pointForFn, latLngForFn); return javaClass.New(env, constructor, reinterpret_cast<jlong>(nativePeer.release()), bitmap, jni::Make<jni::Array<jni::String>>(env, attributions), (jni::jboolean) showLogo); } diff --git a/platform/android/src/snapshotter/map_snapshot.hpp b/platform/android/src/snapshotter/map_snapshot.hpp index 48dd1b6049..f168be85b4 100644 --- a/platform/android/src/snapshotter/map_snapshot.hpp +++ b/platform/android/src/snapshotter/map_snapshot.hpp @@ -17,6 +17,7 @@ class MapSnapshot { public: using PointForFn = mbgl::MapSnapshotter::PointForFn; + using LatLngForFn = mbgl::MapSnapshotter::LatLngForFn; static constexpr auto Name() { return "com/mapbox/mapboxsdk/snapshotter/MapSnapshot"; }; @@ -27,10 +28,11 @@ public: float pixelRatio, std::vector<std::string> attributions, bool showLogo, - PointForFn pointForFn); + PointForFn pointForFn, + LatLngForFn latLngForFn); MapSnapshot(jni::JNIEnv&) {}; - MapSnapshot(float pixelRatio, PointForFn); + MapSnapshot(float pixelRatio, PointForFn, LatLngForFn); ~MapSnapshot(); jni::Object<PointF> pixelForLatLng(jni::JNIEnv&, jni::Object<LatLng>); @@ -41,6 +43,7 @@ private: float pixelRatio; mbgl::MapSnapshotter::PointForFn pointForFn; + mbgl::MapSnapshotter::LatLngForFn latLngForFn; }; } // namespace android diff --git a/platform/android/src/snapshotter/map_snapshotter.cpp b/platform/android/src/snapshotter/map_snapshotter.cpp index e8fcc61770..a93404dbfb 100644 --- a/platform/android/src/snapshotter/map_snapshotter.cpp +++ b/platform/android/src/snapshotter/map_snapshotter.cpp @@ -77,7 +77,7 @@ void MapSnapshotter::start(JNIEnv& env) { snapshotCallback = std::make_unique<Actor<mbgl::MapSnapshotter::Callback>>( *Scheduler::GetCurrent(), - [this](std::exception_ptr err, PremultipliedImage image, std::vector<std::string> attributions, mbgl::MapSnapshotter::PointForFn pointForFn) { + [this](std::exception_ptr err, PremultipliedImage image, std::vector<std::string> attributions, mbgl::MapSnapshotter::PointForFn pointForFn, mbgl::MapSnapshotter::LatLngForFn latLngForFn) { MBGL_VERIFY_THREAD(tid); android::UniqueEnv _env = android::AttachEnv(); @@ -89,7 +89,7 @@ void MapSnapshotter::start(JNIEnv& env) { jni::DeleteLocalRef(*_env, message); } else { // Create the wrapper - auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn); + auto mapSnapshot = android::MapSnapshot::New(*_env, std::move(image), pixelRatio, attributions, showLogo, pointForFn, latLngForFn); // invoke callback static auto onSnapshotReady = javaClass.GetMethod<void (jni::Object<MapSnapshot>)>(*_env, "onSnapshotReady"); |