开发者

Apple documentation incorrect about MKMapView -regionThatFits:?

开发者 https://www.devze.com 2022-12-24 04:48 出处:网络
In the Apple documentation for the -regionThatFits: method of the MKMapView, it says that this will return a new region centered on the same point as the region that\'s passed in, only with the region

In the Apple documentation for the -regionThatFits: method of the MKMapView, it says that this will return a new region centered on the same point as the region that's passed in, only with the regions bounds corrected for the iPhone screen aspect ratio. This seems to be incorrect in implementation...before the call to this method, my region shows up as:

$5 = {
  center = {
    latitude = 37.322898864746094, 
    longitude = -122.03209686279297
  }, 
  span = {
    latitudeDelta = 14.278411865234375, 
    longitudeDelta = 1.5202401876449585
  }
}

..however, after the call to this method, I end up with:

$6 = {
  center = {
    latitude开发者_运维百科 = 36.973427342552824, 
    longitude = -122.03209686279297
  }, 
  span = {
    latitudeDelta = 14.521333317196799, 
    longitudeDelta = 14.0625
  }
}

This is quite a big difference on the map - this translates to the distance between Cupertino, CA and Santa Cruz, CA. Anyone else experience this discrepancy?


I'd assume it's a rounding issue since you used a large latitudeDelta. To make sure, your center is never altered, you could set the adjusted region first, then re-set the center to the old value by using the centerCoordinate property.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号