I have MKMapView , and I'm trying to rotate the map camera title to follow the users title. I do not want to do auto tracking because it forces a zoom level that I would like to control at the same time.
The fact is that I found that the camera title will return to 0 if it comes with any value between 354 and 6 degrees. For example, when I set the camera title to 2, it will constantly bounce between 2 and 0 until I flip the phone to another title.
My solution was to simply lock it to 0 when between this range, but this is not optimal. Does anyone have any information on why this will happen? The method called when the header changes is as follows:
- (void)setMapCameraPosition { //354,6 if (self.heading <= 6 || self.heading >= 354) { NSLog(@"****nulling heading. self.heading: %d camera.heading: %f", self.heading, self.mapView.camera.heading); self.mapView.camera.heading = 0.0f; } else { NSLog(@"changing heading. self.heading: %d camera.heading: %f", self.heading, self.mapView.camera.heading); self.mapView.camera.heading = (double)self.heading; } }
If I don't have an if statement and just set the camera in my header, then my output ends:
self.heading: 357 camera.heading: -0.000000 self.heading: 357 camera.heading: -0.000000 self.heading: 357 camera.heading: -0.000000
Thus, this means that if I give a value close to the north, it will automatically return to the north in a second to make the map hopping forever.
How can I adjust the title to a degree close to the north, but not really, if the map does not delete my desired title?
source share