【发布时间】:2012-05-02 18:51:05
【问题描述】:
当按下定位按钮时,我有以下代码以用户当前位置为中心:
- (void)locate
{
if (self.curLocation) {
[self.googleMapView setCenterCoordinate:self.curLocation.coordinate animated:YES];
NSLog(@"setting center (%f,%f), but got (%f,%f)", self.curLocation.coordinate.latitude, self.curLocation.coordinate.longitude, self.googleMapView.centerCoordinate.latitude, self.googleMapView.centerCoordinate.longitude);
}
}
NSLog的输出是“设置中心(37.785834,-122.406417), but got (37.785826,-122.406406)”
这意味着 setCenterCoordinate 移动到一个近似坐标而不是指示的那个。这非常不方便,因为当我实现缩放级别时,在同一位置缩小然后再放大(因为 setRegion 也会更改中心坐标)将从旧位置移开。这是违反直觉的,Android 平台 API 不会表现出这种不稳定的行为。
有人可以解释为什么 setCenterCoordinate 不去确切的坐标,如果可能的话,任何方法来确保放大和缩小将具有相同的中心。谢谢。
【问题讨论】:
-
你在改变 MKMapView 的框架吗?
-
我不这么认为...我剥离了所有其他与地图视图相关的代码,这应该是唯一剩下的了。
标签: ios mkmapview zooming centering coordinate