diff options
author | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-03-08 15:53:25 +0200 |
---|---|---|
committer | Ander Conselvan de Oliveira <ander.deoliveira@mapbox.com> | 2019-03-14 18:33:11 +0200 |
commit | 11de777628e9e2c4b219bae3f1a6eabd86f2a3c5 (patch) | |
tree | 202156e7253dbc6cbb5fc5c4a04a98e8ed55e681 /platform/glfw | |
parent | a73cc9d8e363b0b3f4fa66c5d9c34625dffbb7e5 (diff) | |
download | qtlocation-mapboxgl-11de777628e9e2c4b219bae3f1a6eabd86f2a3c5.tar.gz |
[core] Remove optional from Map::setLatLngBounds()
This is a first step into grouping together bounds related Map methods
into one that takes a "BoundOptions" object. LatLngBounds::unbounded()
replaces an undefined optional<LatLngBounds>.
v2: Document LatLngBounds::unbounded()
Diffstat (limited to 'platform/glfw')
-rw-r--r-- | platform/glfw/glfw_view.cpp | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/platform/glfw/glfw_view.cpp b/platform/glfw/glfw_view.cpp index dc5e6b1ecd..86833da6ee 100644 --- a/platform/glfw/glfw_view.cpp +++ b/platform/glfw/glfw_view.cpp @@ -288,7 +288,7 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -170.0 }, mbgl::LatLng { 45.0, 170.0 }), // inside mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, -200.0 }, mbgl::LatLng { 45.0, -160.0 }), // left IDL mbgl::LatLngBounds::hull(mbgl::LatLng { -45.0, 160.0 }, mbgl::LatLng { 45.0, 200.0 }), // right IDL - mbgl::LatLngBounds::world() + mbgl::LatLngBounds::unbounded() }; static size_t nextBound = 0u; static mbgl::AnnotationID boundAnnotationID = std::numeric_limits<mbgl::AnnotationID>::max(); @@ -296,29 +296,27 @@ void GLFWView::onKey(GLFWwindow *window, int key, int /*scancode*/, int action, mbgl::LatLngBounds bound = bounds[nextBound++]; nextBound = nextBound % bounds.size(); - if (bound == mbgl::LatLngBounds::world()) { - view->map->setLatLngBounds({}); + view->map->setLatLngBounds(bound); + + if (bound == mbgl::LatLngBounds::unbounded()) { view->map->removeAnnotation(boundAnnotationID); boundAnnotationID = std::numeric_limits<mbgl::AnnotationID>::max(); - break; - } else { - view->map->setLatLngBounds(bound); - } - - mbgl::Polygon<double> rect; - rect.push_back({ - mbgl::Point<double>{ bound.west(), bound.north() }, - mbgl::Point<double>{ bound.east(), bound.north() }, - mbgl::Point<double>{ bound.east(), bound.south() }, - mbgl::Point<double>{ bound.west(), bound.south() }, - }); - - auto boundAnnotation = mbgl::FillAnnotation { rect, 0.5f, { view->makeRandomColor() }, { view->makeRandomColor() } }; - - if (boundAnnotationID == std::numeric_limits<mbgl::AnnotationID>::max()) { - boundAnnotationID = view->map->addAnnotation(boundAnnotation); } else { - view->map->updateAnnotation(boundAnnotationID, boundAnnotation); + mbgl::Polygon<double> rect; + rect.push_back({ + mbgl::Point<double>{ bound.west(), bound.north() }, + mbgl::Point<double>{ bound.east(), bound.north() }, + mbgl::Point<double>{ bound.east(), bound.south() }, + mbgl::Point<double>{ bound.west(), bound.south() }, + }); + + auto boundAnnotation = mbgl::FillAnnotation { rect, 0.5f, { view->makeRandomColor() }, { view->makeRandomColor() } }; + + if (boundAnnotationID == std::numeric_limits<mbgl::AnnotationID>::max()) { + boundAnnotationID = view->map->addAnnotation(boundAnnotation); + } else { + view->map->updateAnnotation(boundAnnotationID, boundAnnotation); + } } } break; } |