我有下面的代碼中心對用戶的當前位置,當按鈕被按下的定位:的iOS的MKMapView setCenterCoordinate不兌現的確切座標
- (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),但得到(37.785826,-122.406406)「
這意味着setCenterCoordinate移動到近似座標而不是指示的座標。這是非常不方便的,因爲當我實現縮放級別時,放大相同的位置然後放大(因爲setRegion也改變了中心座標)將遠離舊的位置。這是違反直覺的,Android平臺API不會表現出這種不規律的行爲。
有人可以解釋爲什麼setCenterCoordinate沒有去確切的座標,如果可能的話,任何方式來確保縮小out-and-in將有相同的中心。謝謝。
您是否正在更改MKMapView的框架? – 2012-04-21 12:43:54
我不這麼認爲......我剝離了所有其他與mapview相關的代碼,這應該是唯一剩下的東西。 – 2012-04-21 12:59:31