2012-02-03 3 views
0

안녕 얘들 아 맵뷰 기본 앱을 개발 중입니다. 나는 거의 모든 것을지도보기로 해봤지만 두 개의 다른지도보기 지역을 비교할 수없고지도보기의 새로운 영역을 찾을 수 없습니다. 예를 들어 사용자가지도를 드래그하면 지역이 얼마나 변경되었는지 찾을 수 있습니다.두 개의 다른지도보기 지역을 비교하고 그 차이점을 찾는 방법

답변

-1

이 답변은 두 개의지도 지점을 비교하는 방법을 보여줍니다. 지도 지역의 중심 인 link에서 사용할 수 있습니다.

+0

다시 신청 해 주셔서 감사합니다. – Nit

+0

이것은 두 지점이 아닌 두 지점 사이의 거리를 비교하는 질문에 대한 대답이 아닙니다. –

0

먼저 초기지도 영역을 찾아야합니다. 먼저 (당신의 viewDidLoad에서)하여이를 찾을 수 있습니다 ...지도는지도보기이라는 말 :

CLLocationCoordinate2D center = mapView.centerCoordinate; 
CLLocationDegrees lat = center.latitude; 
CLLocationDegrees lon = center.longitude; 

MKCoordinateRegion region = mapView.region; 
MKCoordinateSpan span = region.span; 

//Assuming they have been declared as instance variables of type double 
current_lat_low = lat - span.latitudeDelta/2.0; 
current_lat_high = lat + span.latitudeDelta/2.0; 
current_lon_low = lon - span.longitudeDelta/2.0; 
current_lon_high = lon + span.longitudeDelta/2.0; 

이 당신에게 도시 된 맵의 초기 영역을 제공 할 것입니다. 그렇다면

- (void)mapView:(MKMapView*)mapView regionDidChangeAnimated:(BOOL)animated 
{ 

    CLLocationCoordinate2D center = mapView.centerCoordinate; 
    CLLocationDegrees lat = center.latitude; 
    CLLocationDegrees lon = center.longitude; 

    MKCoordinateRegion region = mapView.region; 
    MKCoordinateSpan span = region.span; 

    double lat_low = lat - span.latitudeDelta/2.0; 
    double lat_high = lat + span.latitudeDelta/2.0; 
    double lon_low = lon - span.longitudeDelta/2.0; 
    double lon_high = lon + span.longitudeDelta/2.0; 

    //do any work comparing the initial lat/lons with the new values 
    ..... 

    //set current lat/lon to be the new lat/lon after work is complete 
    current_lat_low = lat_low; 
    current_lat_high = lat_high; 
    current_lon_low = lon_low; 
    current_lon_high = lon_high; 
} 
관련 문제