Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating MapView according to compass

I'm working on Map application that needs to work like original MapView on iOS. I need to rotate mapview according to compass heading value. I tried MTLocation example also I also tried this answer But my results is not good.

Please see the screen shot.

enter image description here

When I rotate mapview according to heading value Map is rotating but as you can see on screen tiles is missing.

How can I solve this display problem ?

Regards - Fatih

like image 964
fyasar Avatar asked Jan 19 '23 13:01

fyasar


1 Answers

Hy,

I'm the author of MTLocation. Thanks for using it by the way! For this to work you have to make sure, that your MKMapView is a subview of your ViewController's view (and not the view itself). Then you have to increase the frame of your mapView with a simple Pytaghoras - calculation: the width and height must be at least as big as the diagonal: sqrt(visibleWidth[320]^2 + visibleHeight[480-88]^2) = 506.

So that means

 mapView = [[MKMapView alloc] initWithFrame:CGRectMake(-100,-100,520,520)];

Hope that helped, please consider upvoting if it fixed your problem.

like image 121
myell0w Avatar answered Jan 31 '23 08:01

myell0w