当按下定位按钮时,我有以下代码以用户的当前位置为中心:
- (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 不去确切的坐标,如果可能的话,任何方法来确保放大和缩小将具有相同的中心。谢谢。