Compass MapView rotation

I am working on a Map application that should work like the original MapView on iOS. I need to rotate the mapview according to the compass header value. I tried the MTLocation example, also I tried this answer But my results are not good.

See screenshot.

enter image description here

When I rotate the mapview according to the value of the title, the map rotates, but as you can see, it is missing on the screen tile.

How can I solve this problem?

Relationships - Fatih

+4
source share
3 answers

Hy

I am the author of MTLocation. Thanks for using it, by the way! To do this, you need to make sure that your MKMapView is a subview of your ViewController (not the view itself). Then you need to enlarge the frame of your mapView with a simple Pytaghoras calculation: the width and height should be at least equal to the diagonal: sqrt (visibleWidth [320] ^ 2 + visibleHeight [480-88] ^ 2) = 506.

So that means

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

Hope this helps, please consider resolving this issue.

+9
source
  • You can use a larger frame for the MKMapView object. This should probably be a square on each side equal to the length of the device’s diagonal. The problem with this approach is that there are areas of this object that the user will not see, but we still process information similar to the annotation views associated with this region. Other properties, such as visibleMapRect , will be less useful.

  • Another alternative would be to zoom in by scaling the MKMapView object while rotating. But this can make the card blurry (unchecked). You can reduce the area displayed on the map, but this can lead to frequent updates. You can look at the middle where you do not zoom out until the map is rotated at a certain angle. You can also look at the use of two views, where one of the views is disconnected from the screen and updated so that it can replace the view after a certain amount of rotation so that it feels seamless.

0
source

I am working on creating my own map application on the iPhone. I want my cards to rotate as the user rotates. I tried setUserTrackingMode , available in iOS 5, but for some reason it does not work. So I decided to use the MTLocation framework here .

So far I have done the following.

  • created a new project and copied all the .m and .h files into it.
  • Import MapKit.h and MTLocation.h .
  • In Viewcontroller.h , a specific property for mapView (the property for mapView should be defined).
  • In the ViewDidLoad paste the code shown at the end of the page here .

I get a few errors:

  • Unable to see the locateMe button when creating programmatically.
  • Undefined property headingEnabled .
  • myCustomSelector not valid.
  • self.toolbar - the toolbar is not an instance of ViewController .

I tried the code in gist [dot] github [dot] com / 1373050 too, but I get similar errors.

Can someone explain the detailed procedure for this.

0
source

All Articles