coreLocation 정보 - 지리적 위치 역코딩

1278 단어 서버공구.MapKit
CoreLocation에서 얻은 포지셔닝 정보는 모두 경도와 위도 등으로 표시된 지리 정보이다. 흔히 우리는 이를 일반인들이 읽을 수 있는 지리적 위치 묘사로 역인코딩해야 한다. 예를 들어 X국XX시XX구역XX거리XX호이다. 이것은MapKit의 지리적 위치 역방향 인코딩 도구인 MKReverseGeocoder를 사용해야 한다.
사용법:
1. 먼저 프로토콜 MKReverseGeocoderDelegate를 실현해야 한다. 좌표 정보를 서버에 보내고 다시 되돌리는 데 일정한 시간이 걸리기 때문에 막히는 것을 방지하기 위해 메시지를 보낸 후 언제까지 정보를 되돌려줄지 모르기 때문에 정보가 되돌아올 때 의뢰 방법을 알린다.여기서 이 유형을 실현할 때 주로 두 가지 방법을 실현하기 위해 다음과 같다.
- (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 방법으로 요청을 취소합니다.

좋은 웹페이지 즐겨찾기