Created
April 20, 2016 15:58
-
-
Save marmelroy/0fee54bfe69bfbfcbbf7057298fca046 to your computer and use it in GitHub Desktop.
Calculating MKMapCamera's altitude for a distance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let altitude = distance*tan(M_PI*(75.0/180.0)) |
@plindberg
Thank you. I've found a related answer on stackoverflow and came up with quite a similar solution.
https://stackoverflow.com/a/21034410/6292624
Wanted to update that on my devices (iOS 13) and simulators (13, 14) max zoom never causes that much delta with target value. In my case minCenterCoordinateDistance ~875 and max zoom value is ~890, so probably mapKitBugAdjustmentFactor should be removed or significantly reduced.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, it helped me figure out how to do this.
However, I’m not sure where
75.0
comes from, how it relates to the 30° aperture of the map camera you refer to in your tweet.I have verified that the aperture indeed is 30° (see code snippet below), and have also discovered that MapKit is off by a factor of ≈1.55 in
MKMapView.cameraZoomRange
– which I explain in this StackOverflow post.Anyway, here’s my solution: