diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-02-27 17:49:01 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-04 14:45:32 +0200 |
commit | 02f2b9c75c4031c084c177a582f18d3e888596fa (patch) | |
tree | f8ee3cb99c0ad7b14613373407df539bfeddf1d5 /platform | |
parent | 362231e2d02333e301b0ec70c85e5ac4e7741bf3 (diff) | |
download | qtlocation-mapboxgl-02f2b9c75c4031c084c177a582f18d3e888596fa.tar.gz |
[core] Added Map::scaleBy()
Diffstat (limited to 'platform')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 6 | ||||
-rw-r--r-- | platform/qt/src/qmapboxgl.cpp | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index 97c4cde657..2a1afdfe1e 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -487,7 +487,7 @@ void GLFWView::onScroll(GLFWwindow *window, double /*xOffset*/, double yOffset) scale = 1.0 / scale; } - view->map->setZoom(view->map->getZoom() + ::log2(scale), mbgl::ScreenCoordinate { view->lastX, view->lastY }); + view->map->scaleBy(scale, mbgl::ScreenCoordinate { view->lastX, view->lastY }); } void GLFWView::onWindowResize(GLFWwindow *window, int width, int height) { @@ -530,9 +530,9 @@ void GLFWView::onMouseClick(GLFWwindow *window, int button, int action, int modi double now = glfwGetTime(); if (now - view->lastClick < 0.4 /* ms */) { if (modifiers & GLFW_MOD_SHIFT) { - view->map->setZoom(view->map->getZoom() - 1, mbgl::ScreenCoordinate { view->lastX, view->lastY }, mbgl::AnimationOptions{{mbgl::Milliseconds(500)}}); + view->map->scaleBy(0.5, mbgl::ScreenCoordinate { view->lastX, view->lastY }, mbgl::AnimationOptions{{mbgl::Milliseconds(500)}}); } else { - view->map->setZoom(view->map->getZoom() + 1, mbgl::ScreenCoordinate { view->lastX, view->lastY }, mbgl::AnimationOptions{{mbgl::Milliseconds(500)}}); + view->map->scaleBy(2.0, mbgl::ScreenCoordinate { view->lastX, view->lastY }, mbgl::AnimationOptions{{mbgl::Milliseconds(500)}}); } } view->lastClick = now; diff --git a/platform/qt/src/qmapboxgl.cpp b/platform/qt/src/qmapboxgl.cpp index 35ff7f7c29..e512b23901 100644 --- a/platform/qt/src/qmapboxgl.cpp +++ b/platform/qt/src/qmapboxgl.cpp @@ -1126,7 +1126,7 @@ void QMapboxGL::moveBy(const QPointF &offset) can be used for implementing a pinch gesture. */ void QMapboxGL::scaleBy(double scale_, const QPointF ¢er) { - d_ptr->mapObj->setZoom(d_ptr->mapObj->getZoom() + ::log2(scale_), mbgl::ScreenCoordinate { center.x(), center.y() }); + d_ptr->mapObj->scaleBy(scale_, mbgl::ScreenCoordinate { center.x(), center.y() }); } /*! |