diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-08 14:42:34 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2017-08-31 10:17:21 +0300 |
commit | d43757271ee505fa4d3c734ef61944fb03c46806 (patch) | |
tree | 8d5fb5a0de133140af279a32151b8bf737b522bd | |
parent | 3f6f236f7badc708f9c0997cd1cb7dba71a84e04 (diff) | |
download | qtlocation-mapboxgl-d43757271ee505fa4d3c734ef61944fb03c46806.tar.gz |
[node] Cleanup NodeMap::Render
-rw-r--r-- | include/mbgl/map/map.hpp | 3 | ||||
-rw-r--r-- | platform/node/src/node_map.cpp | 27 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 7 |
3 files changed, 15 insertions, 22 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 7d6678dc93..4108725776 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -42,7 +42,8 @@ public: // Register a callback that will get called (on the render thread) when all resources have // been loaded and a complete render occurs. using StillImageCallback = std::function<void (std::exception_ptr)>; - void renderStill(StillImageCallback callback); + void renderStill(StillImageCallback); + void renderStill(const CameraOptions&, MapDebugOptions, StillImageCallback); // Triggers a repaint. void triggerRepaint(); diff --git a/platform/node/src/node_map.cpp b/platform/node/src/node_map.cpp index 7c7082bd09..a2c1a0ea15 100644 --- a/platform/node/src/node_map.cpp +++ b/platform/node/src/node_map.cpp @@ -357,28 +357,13 @@ void NodeMap::startRender(NodeMap::RenderOptions options) { frontend->setSize(options.size); map->setSize(options.size); - if (map->getZoom() != options.zoom) { - map->setZoom(options.zoom); - } - - mbgl::LatLng latLng(options.latitude, options.longitude); - if (map->getLatLng() != latLng) { - map->setLatLng(latLng); - } - - if (map->getBearing() != options.bearing) { - map->setBearing(options.bearing); - } - - if (map->getPitch() != options.pitch) { - map->setPitch(options.pitch); - } - - if (map->getDebug() != options.debugOptions) { - map->setDebug(options.debugOptions); - } + mbgl::CameraOptions camera; + camera.center = mbgl::LatLng { options.latitude, options.longitude }; + camera.zoom = options.zoom; + camera.angle = -options.bearing * mbgl::util::DEG2RAD; + camera.pitch = options.pitch * mbgl::util::DEG2RAD; - map->renderStill([this](const std::exception_ptr eptr) { + map->renderStill(camera, options.debugOptions, [this](const std::exception_ptr eptr) { if (eptr) { error = std::move(eptr); uv_async_send(async); diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 324bcc8b5d..e255c5d0ae 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -169,6 +169,13 @@ void Map::renderStill(StillImageCallback callback) { impl->onUpdate(Update::Repaint); } +void Map::renderStill(const CameraOptions& camera, MapDebugOptions debugOptions, StillImageCallback callback) { + impl->cameraMutated = true; + impl->debugOptions = debugOptions; + impl->transform.jumpTo(camera); + renderStill(std::move(callback)); +} + void Map::triggerRepaint() { impl->onUpdate(Update::Repaint); } |