diff options
-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); } |