diff options
-rw-r--r-- | platform/ios/src/MGLMapView.h | 14 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 36 | ||||
-rw-r--r-- | platform/ios/test/MGLMapViewContentInsetTests.m | 4 |
3 files changed, 18 insertions, 36 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 1b6c989d94..8f27adee9e 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -295,7 +295,7 @@ MGL_EXPORT tab bars, toolbars, and other ancestors that obscure the map view. */ -@property (assign) BOOL automaticallyAdjustContentInset; +@property (assign) BOOL automaticallyAdjustsContentInset; /** A Boolean value indicating whether the map may display scale information. @@ -1324,8 +1324,8 @@ MGL_EXPORT `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - The usage of `automaticallyAdjustsScrollViewInsets` it is been deprecated - use the map view’s property `automaticallyAdjustContentInset`instead. + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated + use the map view’s property `MGLMapView.automaticallyAdjustsContentInset`instead. Changing the value of this property updates the map view immediately. If you want to animate the change, use the `-setContentInset:animated:completionHandler:` @@ -1347,8 +1347,8 @@ MGL_EXPORT `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - The usage of `automaticallyAdjustsScrollViewInsets` it is been deprecated - use the map view’s property `automaticallyAdjustContentInset`instead. + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated + use the map view’s property `MGLMapView.automaticallyAdjustsContentInset`instead. To specify a completion handler to execute after the animation finishes, use the `-setContentInset:animated:completionHandler:` method. @@ -1375,8 +1375,8 @@ MGL_EXPORT `automaticallyAdjustsScrollViewInsets` property is `YES`, the value of this property may be overridden at any time. - The usage of `automaticallyAdjustsScrollViewInsets` it is been deprecated - use the map view’s property `automaticallyAdjustContentInset`instead. + The usage of `automaticallyAdjustsScrollViewInsets` has been deprecated + use the map view’s property `MGLMapView.automaticallyAdjustsContentInset`instead. @param contentInset The new values to inset the content by. @param animated Specify `YES` if you want the map view to animate the change to diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index 486e0ad002..0d6e597708 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -526,8 +526,11 @@ public: // TODO: This warning should be removed when automaticallyAdjustsScrollViewInsets is removed from // the UIViewController api. - NSLog(@"%@ WARNING UIViewController.automaticallyAdjustsScrollViewInsets is deprecated use MGLMapView.automaticallyAdjustContentInset instead.", - NSStringFromClass(self.class)); + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + NSLog(@"%@ WARNING UIViewController.automaticallyAdjustsScrollViewInsets is deprecated use MGLMapView.automaticallyAdjustContentInset instead.", + NSStringFromClass(self.class)); + }); // setup logo // @@ -1050,12 +1053,12 @@ public: return viewController; } -- (void)setAutomaticallyAdjustContentInset:(BOOL)automaticallyAdjustContentInset { - MGLLogDebug(@"Setting automaticallyAdjustContentInset: %@", MGLStringFromBOOL(automaticallyAdjustContentInset)); - _automaticallyAdjustContentInsetHolder = [NSNumber numberWithBool:automaticallyAdjustContentInset]; +- (void)setAutomaticallyAdjustsContentInset:(BOOL)automaticallyAdjustsContentInset { + MGLLogDebug(@"Setting automaticallyAdjustsContentInset: %@", MGLStringFromBOOL(automaticallyAdjustsContentInset)); + _automaticallyAdjustContentInsetHolder = [NSNumber numberWithBool:automaticallyAdjustsContentInset]; } -- (BOOL)automaticallyAdjustContentInset { +- (BOOL)automaticallyAdjustsContentInset { return _automaticallyAdjustContentInsetHolder.boolValue; } @@ -3875,27 +3878,6 @@ public: return [self cameraForCameraOptions:cameraOptions]; } -- (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinate:(CLLocationCoordinate2D)coordinate edgePadding:(UIEdgeInsets)insets { - if (!_mbglMap) - { - return self.residualCamera; - } - - mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets); - padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); - - MGLMapCamera *currentCamera = self.camera; - CGFloat pitch = camera.pitch < 0 ? currentCamera.pitch : camera.pitch; - CLLocationDirection direction = camera.heading < 0 ? currentCamera.heading : camera.heading; - - std::vector<mbgl::LatLng> latLngs; - latLngs.reserve(1); - latLngs.push_back({coordinate.latitude, coordinate.longitude}); - - mbgl::CameraOptions cameraOptions = self.mbglMap.cameraForLatLngs(latLngs, padding, direction, pitch); - return [self cameraForCameraOptions:cameraOptions]; -} - - (MGLMapCamera *)camera:(MGLMapCamera *)camera fittingCoordinateBounds:(MGLCoordinateBounds)bounds edgePadding:(UIEdgeInsets)insets { if (!_mbglMap) diff --git a/platform/ios/test/MGLMapViewContentInsetTests.m b/platform/ios/test/MGLMapViewContentInsetTests.m index 8a4a74ceb3..185baf4a05 100644 --- a/platform/ios/test/MGLMapViewContentInsetTests.m +++ b/platform/ios/test/MGLMapViewContentInsetTests.m @@ -145,7 +145,7 @@ expectedAttributionOrigin = CGPointMake(x, y); XCTAssertTrue(CGPointEqualToPoint(attributionView.frame.origin, expectedAttributionOrigin)); - self.mapView.automaticallyAdjustContentInset = YES; + self.mapView.automaticallyAdjustsContentInset = YES; insets = UIEdgeInsetsMake(100, 100, 100, 100); self.mapView.contentInset = insets; XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(self.mapView.contentInset, insets)); @@ -153,7 +153,7 @@ [self.mapView setNeedsLayout]; [self.mapView layoutIfNeeded]; - // when automaticallyAdjustContentInset = YES the content insets should be overwrited + // when automaticallyAdjustsContentInset = YES the content insets should be overwriten XCTAssertFalse(UIEdgeInsetsEqualToEdgeInsets(self.mapView.contentInset, insets)); expectedScaleBarOrigin = CGPointMake(margin, margin); |