我想用iphone gps功能顯示用戶的當前位置,但問題是它給出了錯誤的位置。 當我放置在地圖上的銷釘,然後它丟棄銷在確切的位置,但是當我嘗試在文本中看到的位置,然後它給不準確的位置與500至800米approx.I我已經使用反向地理編碼和谷歌API,但都給予相同位置。請告訴我爲什麼發生這種情況,我如何顯示用戶的確切位置? 我的代碼是:iphone gps給出錯誤的位置
cllocationmanager *locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone; // whenever we move
locationManager.desiredAccuracy = kCLLocationAccuracyBest; // 100 m
[locationManager startUpdatingLocation];
}
}
- (void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
CLLocationCoordinate2D here = newLocation.coordinate;
NSLog(@"%f %f ", here.latitude, here.longitude);
MKReverseGeocoder *geocoder = [[MKReverseGeocoder alloc] initWithCoordinate:here];
[geocoder setDelegate:self];
[geocoder start];
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark
{
NSLog(@"The geocoder has returned: %@", [placemark addressDictionary]);
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:[NSString stringWithFormat:@"%@",[placemark addressDictionary]] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
[alertView release];
}
你可以說你是如何驗證位置?你是否正在使用具有不同數據的地圖? – JeremyP