summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/ios/src/MGLMapView.mm19
1 files changed, 14 insertions, 5 deletions
diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm
index 92d3724b03..6d2b54d4b4 100644
--- a/platform/ios/src/MGLMapView.mm
+++ b/platform/ios/src/MGLMapView.mm
@@ -250,6 +250,8 @@ public:
@property (nonatomic) CFTimeInterval frameTime;
@property (nonatomic) CFTimeInterval averageFrameTime;
+@property (nonatomic, getter=isCameraAltitudeAffectedByPitch) BOOL cameraAltitudeAffectedByPitch;
+
@end
@implementation MGLMapView
@@ -599,6 +601,8 @@ public:
[MGLMapboxEvents pushTurnstileEvent];
[MGLMapboxEvents pushEvent:MMEEventTypeMapLoad withAttributes:@{}];
}
+
+ _cameraAltitudeAffectedByPitch = YES;
}
- (mbgl::Size)size
@@ -2388,7 +2392,8 @@ public:
auto camera = _mbglMap->getStyle().getDefaultCamera();
CGFloat pitch = *camera.pitch;
CLLocationDirection heading = mbgl::util::wrap(*camera.angle, 0., 360.);
- CLLocationDistance distance = MGLAltitudeForZoomLevel(*camera.zoom, pitch, 0, self.frame.size);
+ CGFloat 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
pitch:pitch
@@ -3371,7 +3376,8 @@ public:
{
CLLocationDegrees peakLatitude = (self.centerCoordinate.latitude + camera.centerCoordinate.latitude) / 2;
CLLocationDegrees peakPitch = (self.camera.pitch + camera.pitch) / 2;
- animationOptions.minZoom = MGLZoomLevelForAltitude(peakAltitude, peakPitch,
+ CGFloat pitchForAltitude = self.isCameraAltitudeAffectedByPitch ? peakPitch : 0.0;
+ animationOptions.minZoom = MGLZoomLevelForAltitude(peakAltitude, pitchForAltitude,
peakLatitude, self.frame.size);
}
if (completion)
@@ -3464,7 +3470,8 @@ 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();
- CLLocationDistance altitude = MGLAltitudeForZoomLevel(zoomLevel, pitch, centerCoordinate.latitude, self.frame.size);
+ CGFloat 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];
}
@@ -3478,7 +3485,8 @@ public:
options.center = MGLLatLngFromLocationCoordinate2D(camera.centerCoordinate);
}
options.padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
- options.zoom = MGLZoomLevelForAltitude(camera.altitude, camera.pitch,
+ CGFloat pitchForAltitude = self.isCameraAltitudeAffectedByPitch ? camera.pitch : 0.0;
+ options.zoom = MGLZoomLevelForAltitude(camera.altitude, pitchForAltitude,
camera.centerCoordinate.latitude,
self.frame.size);
if (camera.heading >= 0)
@@ -5202,8 +5210,9 @@ public:
camera.heading = self.directionByFollowingWithCourse;
if (self.zoomLevel < MGLMinimumZoomLevelForUserTracking)
{
+ CGFloat pitchForAltitude = self.isCameraAltitudeAffectedByPitch ? camera.pitch : 0.0;
camera.altitude = MGLAltitudeForZoomLevel(MGLDefaultZoomLevelForUserTracking,
- camera.pitch,
+ pitchForAltitude,
camera.centerCoordinate.latitude,
self.frame.size);
}