summaryrefslogtreecommitdiff
path: root/src/mbgl/map/transform_state.cpp
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2016-02-10 15:15:29 -0800
committerMinh Nguyễn <mxn@1ec5.org>2016-02-10 15:15:29 -0800
commitbd59ab9a5285bf56ecc7a02e180a21f269ad68c0 (patch)
treeb1c6be1c99cd940ed08955aefcb8994ae03c1c52 /src/mbgl/map/transform_state.cpp
parent71611ec61247593aa6e9b568595114647363532d (diff)
downloadqtlocation-mapboxgl-bd59ab9a5285bf56ecc7a02e180a21f269ad68c0.tar.gz
[core, ios, osx] Only constrain after adding to a window
Introduced a setter/getter for constrain mode. On iOS and OS X, the zoom level inspectable causes the zoom level to be set independently from the longitude and latitude. Thus, the latitude inspectable had no effect because the latitude was constrained to 0 at z0. Temporarily removing the heightwise constraint allows the map to center on the intended location before zooming, which is the usual case for storyboards and XIBs. On iOS, the only guarantee we have timing-wise is that all the inspectables are applied after initialization but before the view is added to a window. So we reimpose the heightwise constraint as soon as the view is added to a window, that is, before the user has a chance to pan the map out of bounds. Fixes #3868.
Diffstat (limited to 'src/mbgl/map/transform_state.cpp')
-rw-r--r--src/mbgl/map/transform_state.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mbgl/map/transform_state.cpp b/src/mbgl/map/transform_state.cpp
index 5e74f76229..009534fc8b 100644
--- a/src/mbgl/map/transform_state.cpp
+++ b/src/mbgl/map/transform_state.cpp
@@ -94,6 +94,12 @@ double TransformState::getNorthOrientationAngle() const {
return angleOrientation;
}
+#pragma mark - Constrain mode
+
+ConstrainMode TransformState::getConstrainMode() const {
+ return constrainMode;
+}
+
#pragma mark - Position
LatLng TransformState::getLatLng() const {
@@ -367,8 +373,10 @@ void TransformState::constrain(double& scale_, double& x_, double& y_) const {
x_ = std::max(-max_x, std::min(x_, max_x));
}
- double max_y = (scale_ * util::tileSize - (rotatedNorth() ? width : height)) / 2;
- y_ = std::max(-max_y, std::min(y_, max_y));
+ if (constrainMode != ConstrainMode::None) {
+ double max_y = (scale_ * util::tileSize - (rotatedNorth() ? width : height)) / 2;
+ y_ = std::max(-max_y, std::min(y_, max_y));
+ }
}
void TransformState::moveLatLng(const LatLng& latLng, const PrecisionPoint& anchor) {