views:

345

answers:

1

On an iPhone 3Gs, if you click the little "show my location" symbol on the lower left of the window twice, it switches to a mode that causes the map to rotate so that north on the map faces towards north according to the compass. I don't have a 3Gs, so I just found out about this from a buddy who does have one.

I tried applying a rotation transformation to a MKMapView's layer, like this:

CATransform3D rotationTransform = CATransform3DIdentity;  
rotationTransform = CATransform3DRotate(rotationTransform, degreesToRadians(-20), 0.0, 0.0, 1.0);  
theMapView.layer.transform = rotationTransform;

That sort of works, but not really. The contents of the map do rotate, but the frame rotates and stretches. The map view ends up in a strip that stretches diagonally across the screen, and it ends up under the buttons in my view.

I tried enclosing the map in another view to isolate it, but that doesn't work either. Next I'll try rotating the enclosing view, but I'm hoping somebody else has figured this out. Getting it to work by trial and error is likely to be difficult at best.

Regards,

Duncan C

A: 

Would you be able to provide some sample code on how you did this. I seem to be muddling through xcode and getting errors with trying to implement this.

Appreciate you sharing your knowledge

Matthew
Matthew,I was not able to get it to work. I posted the code that I tried. That code rotates the map view, but also rotates the frame of the view, so the map doesn't stay where you put it and starts covering other fields on your view.The code I posted is what you need in order to try what I did. If you don't know how to make that code work I'm not sure what else to post.Duncan C
Duncan C