diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | include/mbgl/map/map.hpp | 4 | ||||
-rw-r--r-- | include/mbgl/map/mode.hpp | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 7 | ||||
-rw-r--r-- | platform/osx/src/MGLMapView.mm | 25 | ||||
-rw-r--r-- | src/mbgl/map/map.cpp | 10 | ||||
-rw-r--r-- | src/mbgl/map/transform.cpp | 11 | ||||
-rw-r--r-- | src/mbgl/map/transform.hpp | 4 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/map/transform_state.hpp | 3 |
10 files changed, 65 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index ebb4e0f498..edb6743fa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ Known issues: - Corrected the dynamic framework’s minimum deployment target to iOS 8.0. ([#3872](https://github.com/mapbox/mapbox-gl-native/pull/3872)) - Fixed Fabric compatibility. ([#3847](https://github.com/mapbox/mapbox-gl-native/pull/3847)) - Fixed a crash that can occur when reselecting an annotation. ([#3881](https://github.com/mapbox/mapbox-gl-native/pull/3881)) +- Fixed an issue preventing the Latitude inspectable from working when it is set before setting the Zoom Level inspectable in Interface Builder. ([#3886](https://github.com/mapbox/mapbox-gl-native/pull/3886)) - Fixed an issue preventing `-[MGLMapViewDelegate mapView:tapOnCalloutForAnnotation:]` from being called when a non-custom callout view is tapped. ([#3875](https://github.com/mapbox/mapbox-gl-native/pull/3875)) ## iOS 3.1.0 diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 3a85030169..1afe7e86f6 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -138,6 +138,10 @@ public: // North Orientation void setNorthOrientation(NorthOrientation); NorthOrientation getNorthOrientation() const; + + // Constrain mode + void setConstrainMode(ConstrainMode); + ConstrainMode getConstrainMode() const; // Size uint16_t getWidth() const; diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index c197b28589..7fd1a7f522 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -24,6 +24,7 @@ enum class GLContextMode : EnumType { // We can choose to constrain the map both horizontally or vertically, or only // vertically e.g. while panning. enum class ConstrainMode : EnumType { + None, HeightOnly, WidthAndHeight, }; diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index bb71a4c63a..31058c3de2 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -314,7 +314,7 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) _mbglFileSource = new mbgl::DefaultFileSource([fileCachePath UTF8String], [[[[NSBundle mainBundle] resourceURL] path] UTF8String]); // setup mbgl map - _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); + _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None); // start paused if in IB if (_isTargetingInterfaceBuilder || background) { @@ -920,6 +920,11 @@ mbgl::Duration MGLDurationInSeconds(NSTimeInterval duration) BOOL isVisible = self.superview && self.window; if (isVisible && ! _displayLink) { + if (_mbglMap->getConstrainMode() == mbgl::ConstrainMode::None) + { + _mbglMap->setConstrainMode(mbgl::ConstrainMode::HeightOnly); + } + _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updateFromDisplayLink)]; _displayLink.frameInterval = MGLTargetFrameInterval; [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes]; diff --git a/platform/osx/src/MGLMapView.mm b/platform/osx/src/MGLMapView.mm index 065a3a00c2..73cbb7fe80 100644 --- a/platform/osx/src/MGLMapView.mm +++ b/platform/osx/src/MGLMapView.mm @@ -249,7 +249,7 @@ public: NSString *cachePath = cacheURL ? cacheURL.path : @""; _mbglFileSource = new mbgl::DefaultFileSource(cachePath.UTF8String, [[[[NSBundle mainBundle] resourceURL] path] UTF8String]); - _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous); + _mbglMap = new mbgl::Map(*_mbglView, *_mbglFileSource, mbgl::MapMode::Continuous, mbgl::GLContextMode::Unique, mbgl::ConstrainMode::None); // Install the OpenGL layer. Interface Builder’s synchronous drawing means // we can’t display a map, so don’t even bother to have a map layer. @@ -559,19 +559,24 @@ public: } - (void)viewDidMoveToWindow { - if (self.dormant && self.window) { + NSWindow *window = self.window; + if (self.dormant && window) { _mbglMap->resume(); self.dormant = NO; } - [self.window addObserver:self - forKeyPath:@"contentLayoutRect" - options:NSKeyValueObservingOptionInitial - context:NULL]; - [self.window addObserver:self - forKeyPath:@"titlebarAppearsTransparent" - options:NSKeyValueObservingOptionInitial - context:NULL]; + if (window && _mbglMap->getConstrainMode() == mbgl::ConstrainMode::None) { + _mbglMap->setConstrainMode(mbgl::ConstrainMode::HeightOnly); + } + + [window addObserver:self + forKeyPath:@"contentLayoutRect" + options:NSKeyValueObservingOptionInitial + context:NULL]; + [window addObserver:self + forKeyPath:@"titlebarAppearsTransparent" + options:NSKeyValueObservingOptionInitial + context:NULL]; } - (BOOL)wantsLayer { diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 2df86a8f1c..7e0fdd29fe 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -395,6 +395,16 @@ NorthOrientation Map::getNorthOrientation() const { return transform->getNorthOrientation(); } +#pragma mark - Constrain mode + +void Map::setConstrainMode(mbgl::ConstrainMode mode) { + transform->setConstrainMode(mode); + update(Update::Repaint); +} + +ConstrainMode Map::getConstrainMode() const { + return transform->getConstrainMode(); +} #pragma mark - Projection diff --git a/src/mbgl/map/transform.cpp b/src/mbgl/map/transform.cpp index b8c816ddc2..0f7af8c9e9 100644 --- a/src/mbgl/map/transform.cpp +++ b/src/mbgl/map/transform.cpp @@ -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, diff --git a/src/mbgl/map/transform.hpp b/src/mbgl/map/transform.hpp index 806413058d..48615421fe 100644 --- a/src/mbgl/map/transform.hpp +++ b/src/mbgl/map/transform.hpp @@ -119,6 +119,10 @@ public: // North Orientation void setNorthOrientation(NorthOrientation); NorthOrientation getNorthOrientation() const; + + // Constrain mode + void setConstrainMode(ConstrainMode); + ConstrainMode getConstrainMode() const; // Transitions bool inTransition() const; 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) { diff --git a/src/mbgl/map/transform_state.hpp b/src/mbgl/map/transform_state.hpp index 2aef5707fa..dfcc1ed1a0 100644 --- a/src/mbgl/map/transform_state.hpp +++ b/src/mbgl/map/transform_state.hpp @@ -36,6 +36,9 @@ public: // North Orientation NorthOrientation getNorthOrientation() const; double getNorthOrientationAngle() const; + + // Constrain mode + ConstrainMode getConstrainMode() const; // Position LatLng getLatLng() const; |