iphone获取地址的详细信息

Posted on 2011-07-14 11:18  Wi丶cn  阅读(388)  评论(0编辑  收藏  举报

- (id)initWithCoordinate:(CLLocationCoordinate2D)coordinate {

if (self = [super init]) {

// Custom initialization

reverseGeocoder = [[MKReverseGeocoder allocinitWithCoordinate:coordinate];

reverseGeocoder.delegate = self;

[reverseGeocoder start];

//⋯⋯

}

return self;

}

 

#pragma mark MKReverseGeocoderDelegate

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error

{

NSString *errorMessage = [error localizedDescription];

UIAlertView *alertView = [[UIAlertView allocinitWithTitle:@"获取详细信息失败"

message:errorMessage

delegate:nil

cancelButtonTitle:@"OK"

otherButtonTitles:nil];

[alertView show];

[alertView release];

}

 

- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark

{

NSLog(@"%@",placemark.locality);

}

 

//=======================================================

 

 

Street = 科韵路 18

Thoroughfare = 科韵路

SubThoroughfare = 18

City = 广州市

SubLocality = 天河区

State = 广东省

SubAdministrativeArea = (null)

ZIP = (null)

Country = 中国

{

City = "广州市";

Country = "中国";

CountryCode = CN;

FormattedAddressLines = (

"中国",

"广东省广州市天河区",

"科韵路18"

);

State = "广东省";

Street = "科韵路18";

SubLocality = "天河区";

SubThoroughfare = "18";

Thoroughfare = "科韵路";

}

 

 

MKPlacemark

@property (nonatomicreadonly) NSDictionary *addressDictionary; //地址字典

@property (nonatomicreadonly) NSString *thoroughfare; //街道名——“科韵路”

@property (nonatomicreadonly) NSString *subThoroughfare; // 门牌号——“18号”

@property (nonatomicreadonly) NSString *locality; //城市——“广州市”

@property (nonatomicreadonly) NSString *subLocality; //区县——“天河区”

@property (nonatomicreadonly) NSString *administrativeArea; //身份——“广东省

@property (nonatomicreadonly) NSString *subAdministrativeArea; //没获取到,不知道是什么东东

@property (nonatomicreadonly) NSString *postalCode; //邮政编码——不知道是什么原因,这里没获取到

@property (nonatomicreadonly) NSString *country; //国家——“中国

@property (nonatomicreadonly) NSString *countryCode; //国家代码——“CN”

Copyright © 2024 Wi丶cn
Powered by .NET 8.0 on Kubernetes