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

cameraThatFitsShape should accept target pitch as well #11387

Closed
bsudekum opened this issue Mar 5, 2018 · 1 comment
Closed

cameraThatFitsShape should accept target pitch as well #11387

bsudekum opened this issue Mar 5, 2018 · 1 comment
Labels
feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general

Comments

@bsudekum
Copy link

bsudekum commented Mar 5, 2018

- (MGLMapCamera *)cameraThatFitsShape:(MGLShape *)shape direction:(CLLocationDirection)direction edgePadding:(NSEdgeInsets)insets {
mbgl::EdgeInsets padding = MGLEdgeInsetsFromNSEdgeInsets(insets);
padding += MGLEdgeInsetsFromNSEdgeInsets(self.contentInsets);
mbgl::CameraOptions cameraOptions = _mbglMap->cameraForGeometry([shape geometryObject], padding, direction);
return [self cameraForCameraOptions:cameraOptions];
}
- (MGLMapCamera *)cameraForCameraOptions:(const mbgl::CameraOptions &)cameraOptions {
CLLocationCoordinate2D centerCoordinate = MGLLocationCoordinate2DFromLatLng(cameraOptions.center ? *cameraOptions.center : _mbglMap->getLatLng());
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);
return [MGLMapCamera cameraLookingAtCenterCoordinate:centerCoordinate
fromDistance:altitude
pitch:pitch
heading:direction];
}

Since the target pitch of the resulting camera is not exposed, internally we're looking at the pitch of the current map view when calculating the resulting camera.

The addition of another argument (pitch) would allow users to go from a pitched view to unpitched view in one fluid motion.

/cc @asheemmamoowala @frederoni @1ec5

@bsudekum bsudekum added iOS Mapbox Maps SDK for iOS bug labels Mar 5, 2018
@1ec5 1ec5 added macOS Mapbox Maps SDK for macOS feature navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general and removed bug labels Mar 6, 2018
@1ec5
Copy link
Contributor

1ec5 commented Mar 6, 2018

Duplicate of #10115.

@1ec5 1ec5 closed this as completed Mar 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Projects
None yet
Development

No branches or pull requests

2 participants