diff options
-rw-r--r-- | platform/ios/src/MGLMapView.h | 33 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 21 |
2 files changed, 29 insertions, 25 deletions
diff --git a/platform/ios/src/MGLMapView.h b/platform/ios/src/MGLMapView.h index 5af70ebff2..b61e748e23 100644 --- a/platform/ios/src/MGLMapView.h +++ b/platform/ios/src/MGLMapView.h @@ -558,9 +558,14 @@ MGL_EXPORT IB_DESIGNABLE /** A Boolean value that determines whether the updating pitch will also affect the altitude. - When this property is set to `YES`, pitch will work independently from altitude. + When this property is set to `NO`, pitch will work independently from altitude. + The default value of this property is YES. + + Setting this property to NO will allow animation libraries outside of this SDK to control the + map camera without the built-in side effect that pitch influences altitude. This will make the + results of using outside animation more predictable and easier to control. */ -@property(nonatomic, getter=isAltitudeUnaffectedByPitch) BOOL altitudeUnaffectedByPitch; +@property(nonatomic, getter=isCameraAltitudeAffectedByPitch) BOOL cameraAltitudeAffectedByPitch; /** A floating-point value that determines the rate of deceleration after the user @@ -864,6 +869,18 @@ MGL_EXPORT IB_DESIGNABLE - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated; /** + Moves the viewpoint to a different location without using a transition. + + Transition animations can be defined by other classes and use this method to + update the map. + + @param camera The new viewpoint. + @param edgePadding The minimum padding (in screen points) that would be visible + + */ +- (void)setCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)edgePadding; + +/** Moves the viewpoint to a different location with respect to the map with an optional transition duration and timing function. @@ -959,18 +976,6 @@ MGL_EXPORT IB_DESIGNABLE - (void)flyToCamera:(MGLMapCamera *)camera withDuration:(NSTimeInterval)duration peakAltitude:(CLLocationDistance)peakAltitude completionHandler:(nullable void (^)(void))completion; /** - Moves the viewpoint to a different location without using a transition. - - Transition animations can be defined by other classes and use this method to - update the map. - - @param camera The new viewpoint. - @param padding The minimum padding (in screen points) that would be visible - - */ -- (void)jumpToCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)insets; - -/** Returns the camera that best fits the given coordinate bounds. @param bounds The coordinate bounds to fit to the receiver’s viewport. diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index c2d81426c0..297c87961f 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -537,7 +537,7 @@ public: _hapticFeedbackEnabled = YES; - _altitudeUnaffectedByPitch = NO; + _cameraAltitudeAffectedByPitch = YES; _decelerationRate = MGLMapViewDecelerationRateNormal; @@ -2354,7 +2354,7 @@ public: auto camera = _mbglMap->getStyle().getDefaultCamera(); CGFloat pitch = *camera.pitch; CLLocationDirection heading = mbgl::util::wrap(*camera.angle, 0., 360.); - CLLocationDegrees pitchForAltitude = self.altitudeUnaffectedByPitch ? 0.0 : pitch; + CLLocationDegrees pitchForAltitude = self.isCameraAltitudeAffectedByPitch ? pitch : 0.0; CLLocationDistance distance = MGLAltitudeForZoomLevel(*camera.zoom, pitchForAltitude, 0, self.frame.size); self.camera = [MGLMapCamera cameraLookingAtCenterCoordinate:MGLLocationCoordinate2DFromLatLng(*camera.center) fromDistance:distance @@ -3260,6 +3260,11 @@ public: [self setCamera:camera animated:NO]; } +- (void)setCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)edgePadding +{ + [self setCamera:camera withDuration:0 animationTimingFunction:nil edgePadding:edgePadding completionHandler:nil]; +} + - (void)setCamera:(MGLMapCamera *)camera animated:(BOOL)animated { [self setCamera:camera withDuration:animated ? MGLAnimationDuration : 0 animationTimingFunction:nil]; @@ -3377,12 +3382,6 @@ public: self.cameraChangeReasonBitmask &= ~MGLCameraChangeReasonTransitionCancelled; } -- (void)jumpToCamera:(MGLMapCamera *)camera edgePadding:(UIEdgeInsets)insets -{ - mbgl::CameraOptions options = [self cameraOptionsObjectForAnimatingToCamera:camera edgePadding:insets]; - _mbglMap->jumpTo(options); -} - - (MGLMapCamera *)cameraThatFitsCoordinateBounds:(MGLCoordinateBounds)bounds { return [self cameraThatFitsCoordinateBounds:bounds edgePadding:UIEdgeInsetsZero]; @@ -3437,7 +3436,7 @@ public: double zoomLevel = cameraOptions.zoom ? *cameraOptions.zoom : self.zoomLevel; CLLocationDirection direction = cameraOptions.angle ? mbgl::util::wrap(-MGLDegreesFromRadians(*cameraOptions.angle), 0., 360.) : self.direction; CGFloat pitch = cameraOptions.pitch ? MGLDegreesFromRadians(*cameraOptions.pitch) : _mbglMap->getPitch(); - CLLocationDegrees pitchForAltitude = self.altitudeUnaffectedByPitch ? 0.0 : pitch; + CLLocationDegrees pitchForAltitude = self.isCameraAltitudeAffectedByPitch ? pitch : 0.0; CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitchForAltitude, centerCoordinate.latitude, self.frame.size); return [MGLMapCamera cameraLookingAtCenterCoordinate:centerCoordinate fromDistance:altitude pitch:pitch heading:direction]; } @@ -3452,7 +3451,7 @@ public: options.center = MGLLatLngFromLocationCoordinate2D(camera.centerCoordinate); } options.padding = MGLEdgeInsetsFromNSEdgeInsets(insets); - CLLocationDegrees pitch = (self.altitudeUnaffectedByPitch) ? 0.0 : camera.pitch; + CLLocationDegrees pitch = (self.isCameraAltitudeAffectedByPitch) ? camera.pitch : 0.0; options.zoom = MGLZoomLevelForAltitude(camera.altitude, pitch, camera.centerCoordinate.latitude, self.frame.size); @@ -5155,7 +5154,7 @@ public: MGLMapCamera *camera = self.camera; camera.centerCoordinate = self.userLocation.location.coordinate; camera.heading = self.directionByFollowingWithCourse; - CLLocationDegrees pitch = (self.altitudeUnaffectedByPitch) ? 0.0 : camera.pitch; + CLLocationDegrees pitch = (self.isCameraAltitudeAffectedByPitch) ? camera.pitch : 0.0; if (self.zoomLevel < MGLMinimumZoomLevelForUserTracking) { camera.altitude = MGLAltitudeForZoomLevel(MGLDefaultZoomLevelForUserTracking, |