Get heading towards a coordinate in MapKit

I'm trying to create turn-by-turn directions, and I want to create a follow effect. To do that I want the map camera heading to be pointed towards the next coordinate on the map. How would I find the heading from the user location to the next coordinate in MapKit with Swift?
Answered by Frameworks Engineer in 614916022
The best way to accomplish this would be to use the following MKMapCamera initializer:

Code Block
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D,
fromEyeCoordinate eyeCoordinate: CLLocationCoordinate2D,
eyeAltitude: CLLocationDistance)


passing in the next maneuver's location as centerCoordinate and the user's location as eyeCoordinate. Then set MKMapView.camera to the resulting MKMapCamera.
The best way to accomplish this would be to use the following MKMapCamera initializer:

Code Block
convenience init(lookingAtCenter centerCoordinate: CLLocationCoordinate2D,
fromEyeCoordinate eyeCoordinate: CLLocationCoordinate2D,
eyeAltitude: CLLocationDistance)


passing in the next maneuver's location as centerCoordinate and the user's location as eyeCoordinate. Then set MKMapView.camera to the resulting MKMapCamera.
Get heading towards a coordinate in MapKit
 
 
Q