[ios] Proper limiting behavior when trying to zoom out fully
- Bail from quick zoom if new zoom is same as old zoom - Allow pinch gesture at minZoom to still move the map
This commit is contained in:
committed by
Jason Wray
parent
fa0b307680
commit
0cdef85798
@@ -6,6 +6,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT
|
||||
|
||||
* Reduced the size of the dynamic framework by optimizing symbol visibility. ([#7604](https://github.com/mapbox/mapbox-gl-native/pull/7604))
|
||||
* Fixed an issue where the attribution button would have its custom tint color reset when the map view received a tint color change notification, such as when an alert controller was presented. ([#9598](https://github.com/mapbox/mapbox-gl-native/pull/9598))
|
||||
* Improved the behavior of zoom gestures when the map reaches the minimum zoom limit. ([#9626](https://github.com/mapbox/mapbox-gl-native/pull/9626))
|
||||
* Bitcode symbol maps (.bcsymbolmap files) are now included with the dynamic framework. ([#9613](https://github.com/mapbox/mapbox-gl-native/pull/9613))
|
||||
|
||||
## 3.6.0 - June 29, 2017
|
||||
|
||||
@@ -1280,8 +1280,6 @@ public:
|
||||
{
|
||||
if ( ! self.isZoomEnabled) return;
|
||||
|
||||
if (_mbglMap->getZoom() <= _mbglMap->getMinZoom() && pinch.scale < 1) return;
|
||||
|
||||
_mbglMap->cancelTransitions();
|
||||
|
||||
CGPoint centerPoint = [self anchorPointForGesture:pinch];
|
||||
@@ -1297,17 +1295,17 @@ public:
|
||||
}
|
||||
else if (pinch.state == UIGestureRecognizerStateChanged)
|
||||
{
|
||||
// Zoom limiting happens at the core level.
|
||||
CGFloat newScale = self.scale * pinch.scale;
|
||||
double zoom = log2(newScale);
|
||||
if (zoom < _mbglMap->getMinZoom()) return;
|
||||
|
||||
double newZoom = log2(newScale);
|
||||
|
||||
// Calculates the final camera zoom, has no effect within current map camera.
|
||||
MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:zoom aroundAnchorPoint:centerPoint];
|
||||
MGLMapCamera *toCamera = [self cameraByZoomingToZoomLevel:newZoom aroundAnchorPoint:centerPoint];
|
||||
|
||||
if (![self.delegate respondsToSelector:@selector(mapView:shouldChangeFromCamera:toCamera:)] ||
|
||||
[self.delegate mapView:self shouldChangeFromCamera:oldCamera toCamera:toCamera])
|
||||
{
|
||||
_mbglMap->setZoom(zoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
|
||||
_mbglMap->setZoom(newZoom, mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y });
|
||||
// The gesture recognizer only reports the gesture’s current center
|
||||
// point, so use the previous center point to anchor the transition.
|
||||
// If the number of touches has changed, the remembered center point is
|
||||
@@ -1655,9 +1653,9 @@ public:
|
||||
{
|
||||
CGFloat distance = [quickZoom locationInView:quickZoom.view].y - self.quickZoomStart;
|
||||
|
||||
CGFloat newZoom = log2f(self.scale) + (distance / 75);
|
||||
CGFloat newZoom = MAX(log2f(self.scale) + (distance / 75), _mbglMap->getMinZoom());
|
||||
|
||||
if (newZoom < _mbglMap->getMinZoom()) return;
|
||||
if (_mbglMap->getZoom() == newZoom) return;
|
||||
|
||||
CGPoint centerPoint = [self anchorPointForGesture:quickZoom];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user