Victor Krusenstråhle Victor Krusenstråhle - 1 month ago 6
iOS Question

How do you set the heading of the map?

I am using Mapbox, and I am trying to follow the user during the users movements thrue the map. But how do I make the camera turn in the same direction as the user does in real life?

//Create a new MKMapCamera object
let newCameraPosition = MGLMapCamera(lookingAtCenterCoordinate: mapView.centerCoordinate, fromDistance: mapView.camera.altitude + 65, pitch: 70, heading: 0)

// Then you could call it like this
mapView.camera = newCameraPosition

// Track users location
self.mapView.setUserTrackingMode(MGLUserTrackingMode.Follow, animated: true);


Thanks!

Answer

You're most of the way there: use MGLUserTrackingModeFollowWithHeading (.FollowWithHeading).