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

Public API to convert between zoom levels and altitudes #5583

Closed
1ec5 opened this issue Jul 5, 2016 · 7 comments
Closed

Public API to convert between zoom levels and altitudes #5583

1ec5 opened this issue Jul 5, 2016 · 7 comments
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

@1ec5
Copy link
Contributor

1ec5 commented Jul 5, 2016

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.

/cc @dapetcu21

@dapetcu21
Copy link

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
Copy link
Contributor

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.

@1ec5
Copy link
Contributor Author

1ec5 commented 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.

@lilykaiser lilykaiser removed this from the ios-v3.7.0 milestone Nov 29, 2017
@marcelofabri
Copy link

Are there any plans to implement this? 😅

@datwelk
Copy link

datwelk commented Jun 7, 2018

What's the current status of this? Need a pull request?

@lilykaiser
Copy link

If you have a pull request, we would be happy to review it @datwelk !

@jjjiia
Copy link

jjjiia commented Sep 10, 2018

Hi, any updates on this feature?

@1ec5 1ec5 added the navigation For the Mapbox Navigation SDK for Android or iOS or navigation use cases in general label Sep 14, 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

8 participants