2

每当我设置 MKMapKit 的 region 属性时,它都会使跨度加倍。

例如:

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)

这里发生了什么?

4

2 回答 2

1

您是否也在为 MapView 设置 region.center ?

看MKMapView的region属性API描述:

“只改变区域的中心坐标仍然会导致跨度隐式变化。这是因为跨度所代表的距离在不同的经纬度上会发生变化,并且地图视图可能需要调整跨度以考虑新位置。如果要在不更改缩放级别的情况下更改中心坐标,请改用 centerCoordinate。

我的解读是,这意味着当您更改 region.center 时,您的区域跨度设置可以被基于中心坐标的计算值覆盖。

于 2009-09-26T22:10:27.790 回答
0

我也在模拟器和设备上都得到它...... iphone SDK 3.0,xcode 3.2。

SDK 3.1 的模拟器也可以做到...现在没有带有 3.1 的设备来尝试它。

他们怎么找不到这个bug??还有什么比加载和保存您的区域更基本的呢?

mapkit 中还有很多其他错误!:-/ 它很弱!

顺便说一句,如果您调用 regionThatFits,您将获得几乎相同的区域。当您尝试设置区域时,它实际上设置了一些接近(但并不总是完全正确)[mapview regionThatFits:yourregion]

于 2009-10-06T05:50:46.890 回答