views:

799

answers:

3

Hi:

I need to rotate the content of the mapView according to the compass value:

float myHeadingValue = newHeading.trueHeading;

and for rotating the map I use this:

[mapView setTransform:CGAffineTransformMakeRotation( [self degreesToRadians:myHeadingValue] )];

but it rotates the view, not the content of the view.

How can I make it to rotate the content, not the whole view?

+1  A: 

I've solved it creating in Interface Builder a smaller UIView and putting the MKMapView into it. The new UIView does not show the leftover map.

isiaatz
I loved this! I did this too...except. REMEMBER to set the view you are containing the MKMapView into as "Clip Subviews" if the containing view is not full screen.
Jann
A: 

Hi,

I'm really intrigued by your answer. Would you mind elaborating a little more? - I've tried rotating the mapView, the containing view and even the 'layer' of each of these too. However each time, I'm still only able to rotate the 460x320 frame. I.e. there's whitespace around the edges :(

Any more additional help would be really appreciated. Thank you!

chrispy
HiIn Interface Builder you have to create an UIView (example 150x150). Put an MKMapView inside the 150x150 UIView, then double-size the mapView (if UIView is 150x150, the mapView will be 300x300) and center it to UIView.Set this attributes to the 150x150 UIView:- Alpha: 1.00- Background: white and opacity 0%- Check only: "Clear context before drawing", "Clip Subviews", "User interaction Enabled". Uncheck others.And for rotating I've used the following:[mapView setTransform:CGAffineTransformMakeRotation( valueFloat )];Hope this will help you :)
isiaatz
Thanks so much for this! - I see what you are doing now; in effect you are simply making the mapView massive, so you never see the offcut white space. This in effect works, however it does prevent a user from initially seeing the extremes of the map. The user, instead, has to zoom in first. I think this is a fix for some instances, but it would be nice if Apple provided this out of the box as part of the framework. Cheers again for your reply.
chrispy
+1  A: 

There may be an issue with the google logo being out of shot doing this though. Apple have contacted me to say that my app contravened the guidelines because the google logo was invisible.

Toby Evetts