내 MKMapView에서 영역 설정과 관련하여 질문이 있습니다.MKMapView Region
내 뷰를 처음로드 할 때 특정 영역을 표시하려면 mapview를 설정해야합니다.
이 지역의 북쪽 동쪽과 서쪽, 남쪽 위도와 경도
은 다음과 같습니다 이것 또한North East Coordinate Lat:59.623724 Long:2.911587
South West Coordinate Lat:49.004833 Long:-11.361825
, 난에 '잠금'이 지역의지도보기를하고 싶습니다. 위의 좌표는 MKMapView의 최대 범위를 나타냅니다. 그러나 단순히 북동과 남서을 검사하는 경우에 해당
- (void)mapView:(MKMapView *)aMapView regionDidChangeAnimated:(BOOL)animated
그들이 내 최대 범위를 초과하는 경우보기를 재설정 내에서 좌표, 그 또한 나에게 허용 될 것이다.
이 문제에 대한 어떤 조언에 감사드립니다.
편집 : 내 질문의 첫 번째 부분에 관해서는 , 나는 다음과 같은 코드를 사용하여 MKMapView에 초기 영역을 설정할 수 있습니다 알아 낸 :
CLLocationCoordinate2D neCoord;
neCoord.latitude = 59.787643;
neCoord.longitude = 3.025857;
CLLocationCoordinate2D swCoord;
swCoord.latitude = 49.394171;
swCoord.longitude = -11.036642;
MKCoordinateRegion region;
region.center.latitude = neCoord.latitude - (neCoord.latitude - swCoord.latitude) * 0.5;
region.center.longitude = neCoord.longitude + (swCoord.longitude - neCoord.longitude) * 0.5;
region.span.latitudeDelta = fabs(neCoord.latitude - swCoord.latitude); // Add a little extra space on the sides
region.span.longitudeDelta = fabs(swCoord.longitude - neCoord.longitude); // Add a little extra space on the sides
region = [self.mapView regionThatFits:region];
[self.mapView setRegion:region animated:YES];
어쩌면 나는 분명하지 않았고, 확대/축소 또는 스크롤링을 사용하지 않으려 고했지만, 필자는이 기능이 필요했지만 경계 상자에 지정된 영역에서만 사용할 수있었습니다. –