如何将UIMapView围绕arrayMKAnnotation居中?

最佳答案

首先,从注释数组中找到最小和最大纬度和经度。然后可以设置区域:

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];

关于iphone - 如何围绕MKAnnotation数组使UIMapView居中?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4044988/

10-11 11:02