iOS:使用CLLocationManager获取准确的反向地理编码?

背景:我希望允许用户在需要的时间内,在几秒内获得他们的位置。 但是,这个位置大多是不准确的。 我想询问用户是否想再次尝试更准确的地址。

问题:如何编码,以保证下一个猜测总是比上次猜测更好。

我曾经尝试过:

CLLocationManager *locationManager; - (CLLocationManager *)locationManager { if (locationManager != nil) { return locationManager; } locationManager = [[CLLocationManager alloc] init]; [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; [locationManager setDelegate:self]; return locationManager; } -(void)myLocationClickedWithCount: (int) count{ [[self locationManager] startUpdatingLocation]; CLLocation *location = [locationManager location]; CLGeocoder *locationGeocoded = [[CLGeocoder alloc] init]; [locationGeocoded reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) { CLPlacemark *placemark = [placemarks objectAtIndex:0]; if (!placemark){ if (count > 0){ //placemark not available, try again after 1 second sleep(1); [self myLocationClickedWithCount:count-1]; } else{ //Unable to get location after 3 tries UIAlertView *locationNotFoundAlert = [[UIAlertView alloc]initWithTitle:@"Unable to Locate" message:@"Would you like to try again?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; locationNotFoundAlert.tag = locationNotFoundAlertTag; [locationNotFoundAlert show]; } }else{ // got location but not accurate. if (location.horizontalAccuracy > accuracyRadius) { UIAlertView *locationInaccurateAlert = [[UIAlertView alloc]initWithTitle:@"Inaccurate Location" message:[NSString stringWithFormat:@"Your GPS shows the radius of %.2f meters. Would you like to try again?",location.horizontalAccuracy] delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; locationInaccurateAlert.tag = locationInaccurateAlertTag; [locationInaccurateAlert show]; }else { address.text = placemark; } } }]; } 

更新当用户再次询问时,猜测可能需要一些时间。 我只是想知道我应该如何编码。 IE:我应该调用[[self locationManager] startUpdatingLocation]; 再次? 或者是否会重置我的位置到目前为止。 因此,如何根据GPS的当前信息,第二次提高我的猜测(GPS越长,精度越好)。

除了…之外,没有什么可以通过代码来实现准确性

  [locationManager setDesiredAccuracy:kCLLocationAccuracyBest]; 

你已经完成了…就我所见,如果你在3G或EDGE上,你的准确度会大大增加(准确度可以达到5-10m)。

你可以参考苹果的这篇文章,谈到iPhone的GPS精度如何工作…

希望这有助于..