iphone之MKReverseGeocoder 地理位置反向编码
2012-02-19 22:36
423 查看
coreLocation中得到的定位信息都是以经度和纬度等表示的地理信息,很多 时候我们需要把它反向编码成普通人能读懂的地理位置描述如:X国XX市XXX区XXX街道XX号,这就需要用到MapKit中的一个地理位置反向编码工
具:MKReverseGeocoder,
用法:
1,首先要实现协议MKReverseGeocoderDelegate,因为将坐标信息发到服务器再反回来需要一定的时间,所以为了防止阻塞,发出信息后并不知到什么时候会返回信息,信息返回时会通知委托方法。这里实现这个类主要时为了实现2个方法如下:
- (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一个反向编码器,然后发出请求了:
MKReverseGeocoder *reverseGeocoder =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
NSLog(@"%g",coordinate.latitude);
NSLog(@"%g",coordinate.longitude);
reverseGeocoder.delegate = self;
[reverseGeocoder start];
MKReverseGeocoder除了start方法,还有cancel方法来取消请求。
具:MKReverseGeocoder,
用法:
1,首先要实现协议MKReverseGeocoderDelegate,因为将坐标信息发到服务器再反回来需要一定的时间,所以为了防止阻塞,发出信息后并不知到什么时候会返回信息,信息返回时会通知委托方法。这里实现这个类主要时为了实现2个方法如下:
- (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一个反向编码器,然后发出请求了:
MKReverseGeocoder *reverseGeocoder =[[MKReverseGeocoder alloc] initWithCoordinate:coordinate];
NSLog(@"%g",coordinate.latitude);
NSLog(@"%g",coordinate.longitude);
reverseGeocoder.delegate = self;
[reverseGeocoder start];
MKReverseGeocoder除了start方法,还有cancel方法来取消请求。
相关文章推荐
- 关于coreLocation - 地理位置反向编码
- CLLocationManager定位经纬度,MKReverseGeocoder地址解析, MKMapView 地图显示 iphone
- google map geocoder 地理位置编码的实例
- 关于coreLocation - 地理位置反向编码
- iphone 反向地理解析 从坐标获得用户的具体位置信息
- IOS-OC-高德地图-反向地理编码 - 坐标转位置
- 关于coreLocation - 地理位置反向编码
- 反向地理编码-显示位置信息
- 通过GPS数据反向地理信息编码, 得到当前位置信息
- iphone 反向地理解析 从坐标获得用户的具体位置信息
- Android 百度地图—反地理编码—获取当前位置附近的大厦楼宇
- BingMap的GeocodeService进行地理位置正向和反向检索--后台实现
- 地图定位 - 定位,持续定位设置,比较两个位置的距离 地理编码 反地理编码
- iOS 地理位置反编码
- 地理编码(根据地址得出位置并且加上自定义的大头针)
- iOS之获取经纬度并通过反向地理编码获取详细地址
- ios6下使用CLGeocoder替换MKReverseGeocoder
- iOS - GeoCoder 地理编码
- 百度地图开发之定位以及反地理编码获取周围地理位置
- Gootip让Twitter成为基于地理位置的问答平台,并发布iPhone应用