开发者

Rotating only the MapView's content

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?

T开发者_StackOverflowhanks


Here is how I'm rotating the MapView (see 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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜