关于coreLocation - 地理位置反向编码
2012-06-08 09:50
274 查看
转自:http://blog.csdn.net/csj1987/article/details/6658895
CoreLocation中得到的定位信息都是以经度和纬度等表示的地理信息,很多时候我们需要把它反向编码成普通人能读懂的地理位置描述如:X国XX市XXX区XXX街道XX号,这就需要用到MapKit中的一个地理位置反向编码工具:MKReverseGeocoder,
用法:
1,首先要实现协议MKReverseGeocoderDelegate,因为将坐标信息发到服务器再反回来需要一定的时间,所以为了防止阻塞,发出信息后并不知到什么时候会返回信息,信息返回时会通知委托方法。这里实现这个类主要时为了实现2个方法如下:
[plain] view
plaincopy
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
NSLog(@"MKReverseGeocoder has failed.");
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
NSLog(@"当前地理信息为:%@",placemark);
}
didFailWithError这个方法是来处理返回错误信息的,didFindPlacemark则是地理信息返回了,地理信息包含在placemark里面,此对象中包含国家,城市,区块,街道等成员变量。
2,然后可以init一个反向编码器,然后发出请求了:
[plain] view
plaincopy
MKReverseGeocoder *reverseGeocoder =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
NSLog(@"%g",coordinate.latitude);
NSLog(@"%g",coordinate.longitude);
reverseGeocoder.delegate = self;
[reverseGeocoder start];
MKReverseGeocoder除了start方法,还有cancel方法来取消请求。
CoreLocation中得到的定位信息都是以经度和纬度等表示的地理信息,很多时候我们需要把它反向编码成普通人能读懂的地理位置描述如:X国XX市XXX区XXX街道XX号,这就需要用到MapKit中的一个地理位置反向编码工具:MKReverseGeocoder,
用法:
1,首先要实现协议MKReverseGeocoderDelegate,因为将坐标信息发到服务器再反回来需要一定的时间,所以为了防止阻塞,发出信息后并不知到什么时候会返回信息,信息返回时会通知委托方法。这里实现这个类主要时为了实现2个方法如下:
[plain] view
plaincopy
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFailWithError:(NSError *)error{
NSLog(@"MKReverseGeocoder has failed.");
}
- (void)reverseGeocoder:(MKReverseGeocoder *)geocoder didFindPlacemark:(MKPlacemark *)placemark{
NSLog(@"当前地理信息为:%@",placemark);
}
didFailWithError这个方法是来处理返回错误信息的,didFindPlacemark则是地理信息返回了,地理信息包含在placemark里面,此对象中包含国家,城市,区块,街道等成员变量。
2,然后可以init一个反向编码器,然后发出请求了:
[plain] view
plaincopy
MKReverseGeocoder *reverseGeocoder =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
NSLog(@"%g",coordinate.latitude);
NSLog(@"%g",coordinate.longitude);
reverseGeocoder.delegate = self;
[reverseGeocoder start];
MKReverseGeocoder除了start方法,还有cancel方法来取消请求。
相关文章推荐
- 关于coreLocation - 地理位置反向编码
- 关于coreLocation - 地理位置反向编码
- iOS开发中使用CoreLocation框架处理地理编码的方法
- iOS地理反地理编码--CoreLocation
- IOS-OC-高德地图-反向地理编码 - 坐标转位置
- iOS CoreLocation框架第三章—— CLGeocoder(地理编码器)和CLPlacemark(获取位置信息)
- 猫猫学iOS 之CoreLocation反地理编码小Demo输入经纬度得到城市
- iphone之MKReverseGeocoder 地理位置反向编码
- 各大地图API关于逆地理位置编码
- iOS 之CoreLocation反地理编码小Demo输入经纬度得到城市
- 猫猫学iOS 之CoreLocation反地理编码小Demo输入经纬度得到城市
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- 【iOS】7.4 定位服务->2.1.3.2 定位 - 官方框架CoreLocation 功能2:地理编码和反地理编码
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- 猫猫学iOS 之CoreLocation地理编码小Demo输入城市得到经纬度
- 通过GPS数据反向地理信息编码, 得到当前位置信息
- AJ学IOS 之CoreLocation地理编码小Demo输入城市得到经纬度
- CoreLocation框架的基本使用 - 地理编码和反地理编码
- iOS利用CoreLocation获取地理位置以及如何在模拟器进行调试
- AJ学IOS 之CoreLocation反地理编码小Demo输入经纬度得到城市