首先谢谢大家,接下来就是我的问题了,核心代码:
for(int idx = 0; idx < route0.polyLine.count; idx++)
{
CLLocationCoordinate2D coordinate = [[route0.polyLine objectAtIndex:idx] coordinate];
minLat = MIN(minLat, coordinate.latitude);
minLon = MIN(minLon, coordinate.longitude);
maxLat = MAX(maxLat, coordinate.latitude);
maxLon = MAX(maxLon, coordinate.longitude);
}
MKCoordinateRegion region;
MKCoordinateSpan span;
span.latitudeDelta = 1.06f*(maxLat - minLat);
span.longitudeDelta = 1.06f*(maxLon - minLon);
CLLocationCoordinate2D location;
location.latitude = (minLat + maxLat)/2;
location.longitude = (minLon + maxLon)/2;
region.span=span;
region.center=location;
[_mapView regionThatFits:region];
[_mapView setRegion:region animated:false];
我的注意是让mapview上的注释刚好适合屏幕,但是如果注释太近,会出现: