diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 13 |
2 files changed, 12 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index f473bbef0b..d907bc623f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Known issues: - MGLMapView properties like `centerCoordinate` and `camera` now offset the center to account for any translucent top or bottom bar. As a result, when user tracking is enabled and the map view is an immediate child of a view controller, the user dot is centered in the unobscured portion of the map view. To override this offset, modify the `contentInset` property; you may also need to set the containing view controller’s `automaticallyAdjustsScrollViewInsets` property to `NO`. ([#3583](https://github.com/mapbox/mapbox-gl-native/pull/3583)) - In user tracking mode, the user dot stays in a fixed position within MGLMapView while the map pans smoothly. A new property, `userLocationVerticalAlignment`, determines the user dot’s fixed position. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589)) - Zooming and rotation gestures no longer disable user tracking mode. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589)) +- User tracking mode starts out at a lower zoom level by default. ([#3589](https://github.com/mapbox/mapbox-gl-native/pull/3589)) - Fixed an issue with small map views not properly fitting annotations within bounds. (#[3407](https://github.com/mapbox/mapbox-gl-native/pull/3407)) - When the user rotates the map to within 7° of true north, the map view now snaps to true north. ([#3403](https://github.com/mapbox/mapbox-gl-native/pull/3403)) - The map view’s background can now be transparent or translucent, as long as the style’s background layer is transparent or translucent and `MGLMapView.opaque` is set to `NO`. ([#3096](https://github.com/mapbox/mapbox-gl-native/pull/3096)) diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index a488c0bd49..3cb8209f1d 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -68,6 +68,13 @@ const NSTimeInterval MGLUserLocationAnimationDuration = 1.0; const CGSize MGLAnnotationUpdateViewportOutset = {150, 150}; const CGFloat MGLMinimumZoom = 3; + +/// Minimum initial zoom level when entering user tracking mode. +const double MGLMinimumZoomLevelForUserTracking = 10.5; + +/// Initial zoom level when entering user tracking mode from a low zoom level. +const double MGLDefaultZoomLevelForUserTracking = 14.0; + const NSUInteger MGLTargetFrameInterval = 1; //Target FPS will be 60 divided by this value /// Tolerance for snapping to true north, measured in degrees in either direction. @@ -3095,7 +3102,7 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) if (std::abs(currentPoint.x - correctPoint.x) > 1.0 || std::abs(currentPoint.y - correctPoint.y) > 1.0) { - if (round(self.zoomLevel) >= 10) + if (self.zoomLevel >= MGLMinimumZoomLevelForUserTracking) { // at sufficient detail, just re-center the map; don't zoom // @@ -3140,7 +3147,9 @@ std::chrono::steady_clock::duration MGLDurationInSeconds(float duration) MGLMapCamera *camera = self.camera; camera.centerCoordinate = self.userLocation.location.coordinate; camera.heading = course; - camera.altitude = newLocation.horizontalAccuracy; + camera.altitude = MGLAltitudeForZoomLevel(MGLDefaultZoomLevelForUserTracking, camera.pitch, + camera.centerCoordinate.latitude, + self.frame.size); __weak MGLMapView *weakSelf = self; [self _flyToCamera:camera withDuration:animated ? -1 : 0 peakAltitude:-1 completionHandler:^{ |