我在iPhone上實現地圖應用程序。我想讓地圖放大用戶的當前位置。 我想根據精確度縮放(模擬地圖應用程序的工作方式)。MKMapView:如何根據精度設置區域跨度?
進出口實現這種方法:
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
我所面臨的問題是,CLLocation爲我提供了,這到底意味着米的屬性horizontalAccuracy和verticalAccuracy,準確性。然而,到中心我用這個地圖:立足horizontalAccuracy
MKCoordinateRegion region;
MKCoordinateSpan span;
region.center = newLocation.coordinate;
span.latitudeDelta=.005; //THIS IS HARDCODED
span.longitudeDelta=.005; //THIS IS HARDCODED
region.span = span;
[mapView setRegion:region animated:YES];
林尋找一種方式來計算latitudeDelta(以度表示)(以米爲單位表示)。
它不需要是一個確切的轉換(我不期待轉換公式,這將需要相當一些計算,包括當前位置),只是一些aprox值。
任何想法?
謝謝。 Gonso
應該標記爲正確的答案。 – chakrit 2012-03-12 09:55:31