首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

反向地质编码用法

2012-08-17 
反向地理编码用法与地图打交道时,有时需要查找经纬度获取地理信息,MapKit提供了一种工具--反向地理编码 MK

反向地理编码用法
与地图打交道时,有时需要查找经纬度获取地理信息,MapKit提供了一种工具--反向地理编码 MKReverseGeocoder

MKReverseGeocoder *reverseGeocoder =[[[MKReverseGeocoder alloc] initWithCoordinate:self.mapView.userLocation.location.coordinate] autorelease];
    NSLog(@"%g",self.mapView.userLocation.location.coordinate.latitude);
    NSLog(@"%g",self.mapView.userLocation.location.coordinate.longitude);
   reverseGeocoder.delegate = self;
    [reverseGeocoder start];

然后实现下面两个代理方法即可获得你想要的地理信息
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
    NSLog(@"MKReverseGeocoder has failed.");
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
    NSLog(@"当前地理信息为:%@",placemark.locality);
}

热点排行