根据经纬度坐标取详细地址(包括国,省,市,街道,号)
2010-12-30 04:38:20 来源:WEB开发网43 NSLog(@"获取失败!");
44 }
45@end
2: 获取当前手机经纬度的详细地址
view sourceprint?01@implementation AddressReverseGeoder
02
03#pragma mark --
04#pragma mark Public
05//根据经纬度开始获取详细地址信息
06- (void)startedReverseGeoderWithLatitude:(double)latitude longitude:(double)longitude{
07 CLLocationCoordinate2D coordinate2D;
08 coordinate2D.longitude = longitude;
09 coordinate2D.latitude = latitude;
10 //
11 MKReverseGeocoder *geoCoder = [[MKReverseGeocoder alloc] initWithCoordinate:coordinate2D];
12 geoCoder.delegate = self;
13 [geoCoder start];
14}
15#pragma mark --
16#pragma mark MKReverseGeocoderDelegate methods
17//获得地址信息
18- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark {
19 NSString *address = [NSString stringWithFormat:@"%@ %@ %@ %@ %@%@",
20 placemark.country,
21 placemark.administrativeArea,
22 placemark.locality,
23 placemark.subLocality,
24 placemark.thoroughfare,
25 placemark.subThoroughfare];
26 NSLog(@"经纬度所对应的详细:%@", address);
27 geocoder = nil;
28}
29//错误处理
30- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error {
31 NSLog(@"error %@" , error);
32}
33#pragma mark --
34#pragma mark Memory management
35- (void)dealloc {
36 [super dealloc];
37}
38@end
更多精彩
赞助商链接