[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.
This commit is contained in:
Minh Nguyễn
2016-02-10 15:15:29 -08:00
committed by Minh Nguyễn
parent 71611ec612
commit bd59ab9a52
10 changed files with 65 additions and 13 deletions

View File

@@ -560,6 +560,17 @@ NorthOrientation Transform::getNorthOrientation() const {
return state.getNorthOrientation();
}
#pragma mark - Constrain mode
void Transform::setConstrainMode(mbgl::ConstrainMode mode) {
state.constrainMode = mode;
state.constrain(state.scale, state.x, state.y);
}
ConstrainMode Transform::getConstrainMode() const {
return state.getConstrainMode();
}
#pragma mark - Transition
void Transform::startTransition(const CameraOptions& camera,