diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index d449379ea6e..147567da193 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 c960c60c789..1d89099d74f 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -1816,18 +1816,17 @@ - (MGLMapCamera *)cameraByPanningWithTranslation:(CGPoint)endPoint panGesture:(U 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