我想縮放我的地圖視圖以顯示至少一個最近註釋的註釋,儘可能最大的縮放以及用戶位置。我試過以下內容:MKMapView - 縮放以適應用戶位置周圍的最近註釋
-(void)zoomToFitNearestAnnotationsAroundUserLocation {
MKMapPoint userLocationPoint = MKMapPointForCoordinate(self.restaurantsMap.userLocation.coordinate);
MKCoordinateRegion region;
if ([self.restaurantsMap.annotations count] > 1) {
for (id<MKAnnotation> annotation in self.restaurantsMap.annotations) {
MKMapPoint annotationPoint = MKMapPointForCoordinate(annotation.coordinate);
CLLocationDistance distanceBetweenAnnotationsAndUserLocation = MKMetersBetweenMapPoints(annotationPoint, userLocationPoint);
region = MKCoordinateRegionMakeWithDistance(self.restaurantsMap.userLocation.coordinate, distanceBetweenAnnotationsAndUserLocation, distanceBetweenAnnotationsAndUserLocation);
}
[self.restaurantsMap setRegion:region animated:YES];
}
}
我該如何設法保存2-3個最近的距離並根據該信息製作一個區域?