diff options
author | Sudarsana Babu Nagineni <sudarsana.babu@mapbox.com> | 2019-03-04 17:33:43 +0200 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2019-03-08 18:36:03 +0200 |
commit | 2f88e8257b83b77f6c06c86c99f542976e7d5199 (patch) | |
tree | 5118632397e15b590c9f96998e367689f0c53fa8 /src/mbgl/map/transform_state.cpp | |
parent | 5954eea345677682479ad5df4d6b059737efd7f0 (diff) | |
download | qtlocation-mapboxgl-2f88e8257b83b77f6c06c86c99f542976e7d5199.tar.gz |
[core] Remove Constrain mode options
setLatLngBounds() API allows the map to be constrained to certain Lat/Lng
limits, so there is no need of having Constrain mode options on Map to
constrain the map boundaries.
Diffstat (limited to 'src/mbgl/map/transform_state.cpp')
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp index e911067c5b..29152c10df 100644 --- a/src/mbgl/map/transform_state.cpp +++ b/src/mbgl/map/transform_state.cpp @@ -8,9 +8,8 @@ namespace mbgl { -TransformState::TransformState(ConstrainMode constrainMode_, ViewportMode viewportMode_) - : constrainMode(constrainMode_) - , viewportMode(viewportMode_) +TransformState::TransformState(ViewportMode viewportMode_) + : viewportMode(viewportMode_) { } @@ -118,12 +117,6 @@ double TransformState::getNorthOrientationAngle() const { return angleOrientation; } -#pragma mark - Constrain mode - -ConstrainMode TransformState::getConstrainMode() const { - return constrainMode; -} - #pragma mark - ViewportMode ViewportMode TransformState::getViewportMode() const { @@ -204,9 +197,8 @@ void TransformState::setMinZoom(const double minZoom) { double TransformState::getMinZoom() const { double test_scale = min_scale; - double unused_x = x; double unused_y = y; - constrain(test_scale, unused_x, unused_y); + constrain(test_scale, unused_y); return scaleZoom(test_scale); } @@ -370,11 +362,7 @@ bool TransformState::rotatedNorth() const { return (orientation == NO::Leftwards || orientation == NO::Rightwards); } -void TransformState::constrain(double& scale_, double& x_, double& y_) const { - if (constrainMode == ConstrainMode::None) { - return; - } - +void TransformState::constrain(double& scale_, double& y_) const { // Constrain scale to avoid zooming out far enough to show off-world areas on the Y axis. const double ratioY = (rotatedNorth() ? size.width : size.height) / util::tileSize; scale_ = util::max(scale_, ratioY); @@ -382,12 +370,6 @@ void TransformState::constrain(double& scale_, double& x_, double& y_) const { // Constrain min/max pan to avoid showing off-world areas on the Y axis. double max_y = (scale_ * util::tileSize - (rotatedNorth() ? size.width : size.height)) / 2; y_ = std::max(-max_y, std::min(y_, max_y)); - - if (constrainMode == ConstrainMode::WidthAndHeight) { - // Constrain min/max pan to avoid showing off-world areas on the X axis. - double max_x = (scale_ * util::tileSize - (rotatedNorth() ? size.height : size.width)) / 2; - x_ = std::max(-max_x, std::min(x_, max_x)); - } } void TransformState::moveLatLng(const LatLng& latLng, const ScreenCoordinate& anchor) { @@ -421,7 +403,7 @@ void TransformState::setLatLngZoom(const LatLng& latLng, double zoom) { void TransformState::setScalePoint(const double newScale, const ScreenCoordinate &point) { double constrainedScale = newScale; ScreenCoordinate constrainedPoint = point; - constrain(constrainedScale, constrainedPoint.x, constrainedPoint.y); + constrain(constrainedScale, constrainedPoint.y); scale = constrainedScale; x = constrainedPoint.x; |