가 여기에 당신을 도울 수를 사용하고 뭔가. CLLocations의 배열에 맞는 MKCoordinateRegion을 제공합니다. 그런 다음 MKMapView setRegion에 전달하기 위해 그 지역을 사용할 수 있습니다 : 애니메이션 : 당신은 아마 이미 설립하고, 당신은 당신이 원하는 것을 할 수있는 MKMapView 및 핵심 위치를 사용하는
// create a region that fill fit all the locations in it
+ (MKCoordinateRegion) getRegionThatFitsLocations:(NSArray *)locations {
// initialize to minimums, maximums
CLLocationDegrees minLatitude = 90;
CLLocationDegrees maxLatitude = -90;
CLLocationDegrees minLongitude = 180;
CLLocationDegrees maxLongitude = -180;
// establish the min and max latitude and longitude
// of all the locations in the array
for (CLLocation *location in locations) {
if (location.coordinate.latitude < minLatitude) {
minLatitude = location.coordinate.latitude;
}
if (location.coordinate.latitude > maxLatitude) {
maxLatitude = location.coordinate.latitude;
}
if (location.coordinate.longitude < minLongitude) {
minLongitude = location.coordinate.longitude;
}
if (location.coordinate.longitude > maxLongitude) {
maxLongitude = location.coordinate.longitude;
}
}
MKCoordinateSpan span;
CLLocationCoordinate2D center;
if ([locations count] > 1) {
// for more than one location, the span is the diff between
// min and max latitude and longitude
span = MKCoordinateSpanMake(maxLatitude - minLatitude, maxLongitude - minLongitude);
// and the center is the min + the span (width)/2
center.latitude = minLatitude + span.latitudeDelta/2;
center.longitude = minLongitude + span.longitudeDelta/2;
} else {
// for a single location make a fixed size span (pretty close in zoom)
span = MKCoordinateSpanMake(0.01, 0.01);
// and the center equal to the coords of the single point
// which will be the coords of the min (or max) coords
center.latitude = minLatitude;
center.longitude = minLongitude;
}
// create a region from the center and span
return MKCoordinateRegionMake(center, span);
}
해야합니다. 내 애플 리케이션에서 내가 표시하고자하는 위치를 알고, 다음 모든 MKMapView 그들을 충분히 넣을 정도로 큰. 위의 방법을 그렇게 도움이 될 것입니다. 그러나 주어진지도 영역에 맞는 위치 목록을 얻고 싶다면 위의 작업과 반대되는 작업을 수행해야합니다.
도움을 주셔서 감사합니다. 그러나 이미 몇 가지 Google 검색을 통해 이러한 링크를 보았습니다. 이 자습서는 매우 간단하며 단일 위치에만 적용됩니다. 더 발전된 것이 있습니까? – gravityone