對於使用CLGeocoder
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
[currentLocation stopUpdatingLocation];
CLLocation *myLocation = [[CLLocation alloc] initWithLatitude:latitudeValue longitude:longitudeValue];
CLGeocoder * geoCoder = [[CLGeocoder alloc] init];
[geoCoder reverseGeocodeLocation:myLocation completionHandler:^(NSArray *placemarks, NSError *error) {
if(!error)
{
for (CLPlacemark * placemark in placemarks)
{
NSLog(@"placemark.ISOcountryCode %@",placemark.ISOcountryCode);
NSLog(@"placemark.country %@",placemark.country);
NSLog(@"placemark.postalCode %@",placemark.postalCode);
NSLog(@"placemark.administrativeArea %@",placemark.administrativeArea);
NSLog(@"placemark.locality %@",placemark.locality);
NSLog(@"placemark.subLocality %@",placemark.subLocality);
NSLog(@"placemark.subThoroughfare %@",placemark.subThoroughfare);
}
}
else
{
NSLog(@"failed getting city: %@", [error description]);
}
}];
}
爲了澄清獲取您的位置的所有細節,我做了一些更多的測試,它似乎沒有蘋果地圖或谷歌地圖iOS版解決這個問題。兩者都會爲丟棄的針腳提供針對街道的特定地址,即使縮小到目前爲止您無法定位到街道。 – 2013-02-13 01:44:58