Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[ios] Fix incorrect center coordinate after pinch gesture #15097

Merged
merged 2 commits into from
Jul 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions platform/ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
* Deprecated variants of the above methods without completion handlers. ([#14959](https://github.com/mapbox/mapbox-gl-native/pull/14959))
* Fixed an issue where the two-finger tilt gesture would continue after lifting one finger. ([#14969](https://github.com/mapbox/mapbox-gl-native/pull/14969))
* Added `MGLMapView.compassView.visibility` and `MGLOrnamentVisibility` to allow configuration of compass visibility behavior. ([#15055](https://github.com/mapbox/mapbox-gl-native/pull/15055))
* Fixed a bug where using the pinch gesture could result in an incorrect map center coordinate. ([#15097](https://github.com/mapbox/mapbox-gl-native/pull/15097))

## 5.1.0 - June 19, 2019

Expand Down
12 changes: 4 additions & 8 deletions platform/ios/src/MGLMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,8 @@ @implementation MGLMapView

NSInteger _changeDelimiterSuppressionDepth;

/// Center coordinate of the pinch gesture on the previous iteration of the gesture.
CLLocationCoordinate2D _previousPinchCenterCoordinate;
/// Center of the pinch gesture on the previous iteration of the gesture.
CGPoint _previousPinchCenterPoint;
NSUInteger _previousPinchNumberOfTouches;

CLLocationDistance _distanceFromOldUserLocation;
Expand Down Expand Up @@ -1643,11 +1643,7 @@ - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch
// meaningless.
if (self.userTrackingMode == MGLUserTrackingModeNone && pinch.numberOfTouches == _previousPinchNumberOfTouches)
{
CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate;
mbgl::EdgeInsets padding { centerPoint.y, centerPoint.x, self.size.height - centerPoint.y, self.size.width - centerPoint.x };
self.mbglMap.jumpTo(mbgl::CameraOptions()
.withCenter(MGLLatLngFromLocationCoordinate2D(centerCoordinate))
.withPadding(padding));
self.mbglMap.moveBy({centerPoint.x - _previousPinchCenterPoint.x, centerPoint.y - _previousPinchCenterPoint.y});
}
}
[self cameraIsChanging];
Expand Down Expand Up @@ -1705,7 +1701,7 @@ - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch
[self unrotateIfNeededForGesture];
}

_previousPinchCenterCoordinate = [self convertPoint:centerPoint toCoordinateFromView:self];
_previousPinchCenterPoint = centerPoint;
_previousPinchNumberOfTouches = pinch.numberOfTouches;
}

Expand Down