2

默认情况下,我们可以在地图视图中显示用户的位置。点击注释引脚时,它将显示“当前位置”。但我想将用户的地址显示为街道、城市和国家。我怎样才能通过使用CLGeoCoder类来做到这一点?

4

1 回答 1

6

做这样的事情:

CLGeocoder *gc = [[[CLGeocoder alloc] init] autorelease];
[gc reverseGeocodeLocation:locationObject completionHandler:^(NSArray *placemark, NSError *error) {
    CLPlacemark *pm = [placemark objectAtIndex:0];
    NSDictionary *address = pm.addressDictionary;
    // do something with the address, see keys in the remark below
}];

以及此处的相关文档:http: //developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html#//apple_ref/occ/instp/CLPlacemark/addressDictionary

于 2012-01-19T19:06:08.720 回答