2013-11-02 69 views
0

我想使用地圖視圖顯示我的當前位置,我的測試設備是Ipad mini(WIFI,IOS7)。IOS MapKit引腳不在當前位置

我更新當前位置到我UIMapView的委託方法

-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations 

{

CLLocation *currentLocation = [locations lastObject]; 
MyAnnotation *start = [[MyAnnotation alloc] init]; 
start.coordinate = currentLocation.coordinate; 

[_mapView addAnnotation:start]; 

MKCoordinateRegion region; 
region = MKCoordinateRegionMakeWithDistance(currentLocation.coordinate, 100, 100); 

[_mapView setRegion:region animated:YES]; 

}

但我得到這樣的照片下面的結果,我現在的位置是在藍色的點,但紅色的針在另一個地方。我認爲這個針腳應該與我目前的位置相匹配,即藍點。但事實並非如此。有人能告訴我理由,謝謝。

enter image description here

+0

嘗試增加您的註解在地圖視圖的委託方法didUpdateUserLocation和使用userLocation.coordinate,而不是你自己的CLLocationManager(CLLocationManager爲它可能使用與地圖視圖的藍點內部位置mgr不同的過濾條件)。 – Anna

+0

我didUpateUserLocation委託方法是像下面的代碼,但它得到相同的結果.-(void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {CLRocationCoordinate2D coordinate = userLocation.location.coordinate; MKCoordinateRegion reg = MKCoordinateRegionMakeWithDistance(coordinate,100,100); mapView.region = reg; } – billwang1990

+0

評論中的代碼不會添加註釋。它只是設置地圖的區域。我建議在didUpdateUserLocation而不是didUpdateLocations中執行addAnnotation(以及設置區域)。 – Anna

回答

0

的原因是,GPS是不是100%準確,尤其不能在建築物內