From 63820d1b4f96b4e2370fd6567a8f77149117620e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguye=CC=82=CC=83n?= Date: Wed, 23 Dec 2015 10:06:51 -0800 Subject: [PATCH] [core] Always constrain width for zoom level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Even if the map supports wrapping the world, it isn’t necessary to show more than one full revolution of the world at a time. Removed a redundant zoom level clamp. --- src/mbgl/map/transform.cpp | 7 ------- src/mbgl/map/transform_state.cpp | 8 +++----- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index 04c0f8bda..7e9c0c4f4 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -212,13 +212,6 @@ double Transform::getScale() const { } void Transform::_setScale(double new_scale, const PrecisionPoint& center, const Duration& duration) { - // Ensure that we don't zoom in further than the maximum allowed. - if (new_scale < state.min_scale) { - new_scale = state.min_scale; - } else if (new_scale > state.max_scale) { - new_scale = state.max_scale; - } - const double factor = new_scale / state.scale; double dx = 0; double dy = 0; diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index ccc5ab365..a41003e0d 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -355,11 +355,9 @@ bool TransformState::rotatedNorth() const { void TransformState::constrain(double& scale_, double& x_, double& y_) const { // Constrain minimum scale to avoid zooming out far enough to show off-world areas. - if (constrainMode == ConstrainMode::WidthAndHeight) { - scale_ = std::max(scale_, static_cast((rotatedNorth() ? height : width) / util::tileSize)); - } - - scale_ = std::max(scale_, static_cast((rotatedNorth() ? width : height) / util::tileSize)); + scale_ = util::max(scale_, + static_cast((rotatedNorth() ? height : width) / util::tileSize), + static_cast((rotatedNorth() ? width : height) / util::tileSize)); // Constrain min/max pan to avoid showing off-world areas. if (constrainMode == ConstrainMode::WidthAndHeight) {