diff options
author | tobrun <tobrun.van.nuland@gmail.com> | 2018-06-26 18:07:18 +0200 |
---|---|---|
committer | Tobrun <tobrun@mapbox.com> | 2018-07-05 18:50:21 +0200 |
commit | 99f9787cc4099b76401ab5b9a9ef7d2f894f9ab6 (patch) | |
tree | 638c3ab0d0c2ed723a841f6528a5ceacc9f3f056 /platform/default | |
parent | 473dd9b23f3bbd933a3af52d896803659f80acfb (diff) | |
download | qtlocation-mapboxgl-99f9787cc4099b76401ab5b9a9ef7d2f894f9ab6.tar.gz |
[core] - add LatLng for screencoordinate to mapsnapshotter
Diffstat (limited to 'platform/default')
-rw-r--r-- | platform/default/mbgl/map/map_snapshotter.cpp | 12 | ||||
-rw-r--r-- | platform/default/mbgl/map/map_snapshotter.hpp | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/platform/default/mbgl/map/map_snapshotter.cpp b/platform/default/mbgl/map/map_snapshotter.cpp index 149ef22e7a..565f72930d 100644 --- a/platform/default/mbgl/map/map_snapshotter.cpp +++ b/platform/default/mbgl/map/map_snapshotter.cpp @@ -87,6 +87,15 @@ void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback) return transform.latLngToScreenCoordinate(unwrappedLatLng); }}; + // Create lambda that captures the current transform state + // and can be used to translate for geographic to screen + // coordinates + assert (frontend.getTransformState()); + LatLngForFn latLngForFn { [=, transformState = *frontend.getTransformState()] (const ScreenCoordinate& screenCoordinate) { + Transform transform { transformState }; + return transform.screenCoordinateToLatLng(screenCoordinate); + }}; + // Collect all source attributions std::vector<std::string> attributions; for (auto source : map.getStyle().getSources()) { @@ -102,7 +111,8 @@ void MapSnapshotter::Impl::snapshot(ActorRef<MapSnapshotter::Callback> callback) error, error ? PremultipliedImage() : frontend.readStillImage(), std::move(attributions), - std::move(pointForFn) + std::move(pointForFn), + std::move(latLngForFn) ); }); } diff --git a/platform/default/mbgl/map/map_snapshotter.hpp b/platform/default/mbgl/map/map_snapshotter.hpp index f40d1e4b77..264f74541d 100644 --- a/platform/default/mbgl/map/map_snapshotter.hpp +++ b/platform/default/mbgl/map/map_snapshotter.hpp @@ -52,8 +52,9 @@ public: LatLngBounds getRegion() const; using PointForFn = std::function<ScreenCoordinate (const LatLng&)>; + using LatLngForFn = std::function<LatLng (const ScreenCoordinate&)>; using Attributions = std::vector<std::string>; - using Callback = std::function<void (std::exception_ptr, PremultipliedImage, Attributions, PointForFn)>; + using Callback = std::function<void (std::exception_ptr, PremultipliedImage, Attributions, PointForFn, LatLngForFn)>; void snapshot(ActorRef<Callback>); private: |