Strange behavior iphone MKMapKit

Whenever I set the MKMapKit scope property it doubles the range.

For example:

MKCoordinateRegion currentRegion = map.region; // assume the current center of region is around New-York and the span is 2 by 2
map.region = map.region; // assign the region to itself
MKCoordinateRegion newRegion = map.region; 
// the span of newRegion is different (almost twice than currentRegion)

      

what's going on here?

+2


source to share


2 answers


Are you setting the region.center for the MapView as well?

Look at the description of the region property of the MKMapView API:



"Changing only the center coordinate of an area can still cause the interval to change implicitly . This is because the distances represented by changing the range vary at different latitudes and longitudes and the map may need to change the range to account new location. If you want to change the center coordinate without changing the zoom level, use centerCoordinate instead. "

My reading is that this means that the settings of the region of the range can be overridden by the computed values ​​based on the center coordinate when the region.center changes.

+1


source


I also get it on both simulator and device ... iphone SDK 3.0, xcode 3.2.

also a simulator for SDK 3.1, he ... he doesn't have a 3.1 device to try it.

How could they not find this error? What could be easier than loading and saving your region?



Lots of other bugs in mapkit too!: - / that's pretty weak!

By the way, if you call regionThatFits you get pretty much the same region. When you try to set a region, it actually sets something close to (but not always accurate) [mapview regionThatFits: yourregion]

0


source







All Articles