views:

399

answers:

1

Hello. I am trying to rotate a map view in my app according the the user's current route. (I don't like to use the built in compasse because only 3GS uses it and it suffers too much interference from other machines, i.e. your own car.).

the CGAffineTransformMakeRotation method will rotate the Whole Map View, so the Google Logo will not be in the lower right of the screen anymore. Also all Annotation Views will rotate and look weird on the App.

Does anyone knows how to rotate just the content (streets drwaings) of the MkMapView?

Thanks

A: 

Here is how I'm rotating the MapView (see http://stackoverflow.com/questions/1245461/rotate-mapview-using-compass-orientation):

[self.mapView setTransform:CGAffineTransformMakeRotation(-1 * currentHeading.magneticHeading * 3.14159 / 180)];

Then to keep the orientation of the annotation views with the top of the device:

for (MKAnnotation *annotation in self.mapView.annotations) {
     MKAnnotationView *annotationView = [self.mapView viewForAnnotation:annotation]; 
     [annotationView setTransform:CGAffineTransformMakeRotation(currentHeading.magneticHeading * 3.14159 / 180)];
}

If you want the point of rotation of the annotationViews to be say the bottom center, I believe you would set each view's anchorPoint as follows:

  annotationView.layer.anchorPoint = CGPointMake(0.5, 1.0);

I'm still having some issues with the annotationView position changing when I do this though (probably same problem as stackoverflow question: changing-my-calayers-anchorpoint-moves-the-view).

rockfakie