如何将UIMapView
围绕array
MKAnnotation
进行居中?
答案 0 :(得分:2)
首先从注释数组中找到最小和最大纬度和经度。然后你可以设置区域:
MKCoordinateRegion extents;
extents.center.latitude = (maxLat + minLat)/2.0;
extents.center.longitude = (maxLong + minLong)/2.0;
extents.span.latitudeDelta = (maxLat - minLat);
extents.span.longitudeDelta = (maxLong - minLong);
MKCoordinateRegion fittedRegion = [mapView regionThatFits:extents];
[mapView setRegion:fittedRegion animated:YES];