看起来你可以用地标做的最好的事情是
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
这篇文章可能对iOS 有一些用处:get Accurate Reverse Geocoding using CLLocationManager?
还值得注意的是,使用波士顿代替布莱顿仍然是同一地点的有效地址。
http://support.apple.com/kb/HT1975
这对我有用:
- (void) resetLocationData{
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
NSLog(@"LAT: %f", [locationManager location].coordinate.latitude);
NSString *latitude = [NSString stringWithFormat:@"%f", [locationManager location].coordinate.latitude];
NSString *longitude = [NSString stringWithFormat:@"%f", [locationManager location].coordinate.longitude];
NSString *latlong = [NSString stringWithFormat:@"%@,%@", latitude, longitude];
NSLog(@"LONG: %f", [locationManager location].coordinate.longitude);
NSLog(@"Combined Location: %@", latlong);
[[locationManager location]timestamp];
}
#pragma mark - CLLOCATION STUFF
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
self.currentLocation = newLocation;
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:self.currentLocation completionHandler:^(NSArray *placemarks, NSError *error)
{
NSLog(@"Placemark is %@", placemarks);
CLPlacemark *place = [placemarks objectAtIndex:0];
NSLog(@"placemark 0: %@", place);
// locationLabel.text = placemarks;
}];
if(newLocation.horizontalAccuracy <= 100.0f) {
[locationManager stopUpdatingLocation];
}
}
日志输出:
2013-01-13 23:23:05.508 CLLocationTest[47617:907] 地标是(“XX XXXXXX Rd, XX XXXXXX Rd, Brighton, MA 02135, United States @ <+42.XXXXXX,-71.XXXXXXX> +/- 100.00m"