I play around the Mapkit
and want to rotate the map follow user's heading. It works with this function:
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
_mapView.centerCoordinate =userLocation.location.coordinate;
self.mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading;
}
However, the moment I rotate the map with 2 fingers and it is gone forever. The beam is not there anymore. I add a button to trigger the heading
:
- (IBAction)showHeading:(id)sender {
[self.mapView setUserTrackingMode:MKUserTrackingModeFollowWithHeading animated:YES];
}
But it seems like it is not working.
What I want to do is the map is always rotate to user heading no matter what I do. Any suggestion will be good for now.
Since it sounds like you want the user tracking annotation features provided by MapKit (the "beam"), you are going to have to either somehow use
MKUserTrackingMode
or else manually recreate the annotation details yourself.I don't have a good sense as to how you could use the tracking mode, since any pan/pinch/rotate gesture (which presumably you want) will disable tracking mode.
But for recreating, I would look into either
SVPulsingAnnotationView
, which gets you partway there, or else the Mapbox iOS SDK, which gives you full control over this sort of thing.