You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Public API to convert between zoom levels and altitudes #5583
featureiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Internally, the iOS and macOS SDKs use MGLAltitudeForZoomLevel() to convert from a zoom level to an altitude given the map view’s current state. This functionality would be useful for developers who want to animate to a given zoom level and pitch or perform other zoom-level-dependent calculations.
Not sure whether MGLAltitudeForZoomLevel() is the best API to expose publicly or whether we should design a wrapper around it in MGLMapCamera.
I noticed that function. Not sure if it's the best thing to expose publicly. It had a difficult signature. Though an API in that direction would be needed.
Just some perspective from an iOS SDK newbie: I recently made some local changes to the iOS bench app, and I got hung up on the altitude-based API while trying to do what I thought would be a simple 10 second zoom animation. The solution I ended up with is obviously non-optimal:
// Set target zoom without animation
[self.mapView setCenterCoordinate:self.mapView.centerCoordinate zoomLevel:location.endZoom animated:NO];
// Save altitude of the target zoom
CLLocationDistance targetAltitude = self.mapView.camera.altitude;
// Put the original zoom back in place
[self.mapView setCenterCoordinate:self.mapView.centerCoordinate zoomLevel:location.zoom animated:NO];
// Animate to the target altitude
MGLMapCamera *camera = [MGLMapCamera cameraLookingAtCenterCoordinate:self.mapView.centerCoordinate fromDistance:targetAltitude pitch:location.pitch heading:location.endBearing];
[self.mapView setCamera:camera withDuration:10 animationTimingFunction:nil];
I saw MGLAltitudeForZoomLevel existed but didn't take the time to look up how best to satisfy all of its dependencies.
Ah, the ol’ set-and-revert dance (also described in mapbox/ios-sdk-examples#65 (review)). It’s worth noting that it’s sometimes possible to avoid this issue entirely by reconsidering whether a zoom level is the best way to express the target viewport. Sometimes an altitude or coordinate bounds better captures the intent. But in cases where you really do want to show tiles at a specific zoom level (perhaps in order to reach a certain camera function stop), MGLAltitudeForZoomLevel() would certainly be useful as a public API.
featureiOSMapbox Maps SDK for iOSmacOSMapbox Maps SDK for macOSnavigationFor the Mapbox Navigation SDK for Android or iOS or navigation use cases in general
Activity
dapetcu21 commentedon Jul 5, 2016
I noticed that function. Not sure if it's the best thing to expose publicly. It had a difficult signature. Though an API in that direction would be needed.
ChrisLoer commentedon Nov 9, 2017
Just some perspective from an iOS SDK newbie: I recently made some local changes to the iOS bench app, and I got hung up on the altitude-based API while trying to do what I thought would be a simple 10 second zoom animation. The solution I ended up with is obviously non-optimal:
I saw
MGLAltitudeForZoomLevelexisted but didn't take the time to look up how best to satisfy all of its dependencies.1ec5 commentedon Nov 10, 2017
Ah, the ol’ set-and-revert dance (also described in mapbox/ios-sdk-examples#65 (review)). It’s worth noting that it’s sometimes possible to avoid this issue entirely by reconsidering whether a zoom level is the best way to express the target viewport. Sometimes an altitude or coordinate bounds better captures the intent. But in cases where you really do want to show tiles at a specific zoom level (perhaps in order to reach a certain camera function stop),
MGLAltitudeForZoomLevel()would certainly be useful as a public API.marcelofabri commentedon May 2, 2018
Are there any plans to implement this? 😅
datwelk commentedon Jun 7, 2018
What's the current status of this? Need a pull request?
lilykaiser commentedon Jun 12, 2018
If you have a pull request, we would be happy to review it @datwelk !
jjjiia commentedon Sep 10, 2018
Hi, any updates on this feature?