From addefe539ac6ad94e4d8526f3cc1da2114ac0585 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Soto Date: Tue, 14 Nov 2017 13:37:45 -0500 Subject: [ios] Fix toCamera.centerCoordinate in shouldChangeFromCamera (#10433) * [ios] Fix toCamera.centerCoordinate in shouldChangeFromCamera has same center as oldCamera. * [ios] Update changelog. * [ios] Remove unnecessary variables. * [ios] Clarify changelog doc. --- platform/ios/CHANGELOG.md | 1 + platform/ios/src/MGLMapView.mm | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index d449379ea6..147567da19 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -37,6 +37,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Users of VoiceOver can now swipe left and right to navigate among visible places, points of interest, and roads. ([#9950](https://github.com/mapbox/mapbox-gl-native/pull/9950)) * Increased the default maximum zoom level from 20 to 22. ([#9835](https://github.com/mapbox/mapbox-gl-native/pull/9835)) +* Fixed an issue where the same value was passed in as the `oldCamera` and `newCamera` parameters to the `-[MGLMapViewDelegate mapView:shouldChangeFromCamera:toCamera:]` method. ([#10433](https://github.com/mapbox/mapbox-gl-native/pull/10433)) ### Other changes diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c002da5f18..41d900702b 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1801,18 +1801,17 @@ public: return panCamera; } -- (MGLMapCamera *)cameraByZoomingToZoomLevel:(double)zoom aroundAnchorPoint:(CGPoint)anchorPoint +- (MGLMapCamera *)cameraByZoomingToZoomLevel:(double)zoom aroundAnchorPoint:(CGPoint)anchorPoint { - mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(self.contentInset); - mbgl::CameraOptions currentCameraOptions = _mbglMap->getCameraOptions(padding); - MGLMapCamera *camera; - mbgl::ScreenCoordinate anchor = mbgl::ScreenCoordinate { anchorPoint.x, anchorPoint.y }; + mbgl::EdgeInsets padding = mbgl::EdgeInsets(anchor.y, anchor.x, self.size.height - anchor.y, self.size.width - anchor.x); + mbgl::CameraOptions currentCameraOptions = _mbglMap->getCameraOptions(padding); + currentCameraOptions.zoom = mbgl::util::clamp(zoom, self.minimumZoomLevel, self.maximumZoomLevel); currentCameraOptions.anchor = anchor; - camera = [self cameraForCameraOptions:currentCameraOptions]; + MGLCoordinateBounds bounds = MGLCoordinateBoundsFromLatLngBounds(_mbglMap->latLngBoundsForCamera(currentCameraOptions)); - return camera; + return [self cameraThatFitsCoordinateBounds:bounds]; } - (MGLMapCamera *)cameraByRotatingToDirection:(CLLocationDirection)degrees aroundAnchorPoint:(CGPoint)anchorPoint -- cgit v1.2.1