如果您知道最高和最低纬度和经度值,您至少可以通过使用MKCoordinateRegionMake
代替来简化一些事情MKCoordinateRegionMakeWithDistance
。也许是这样的:
CLLocationDegrees highestLatitude;
CLLocationDegrees lowestLatitude;
CLLocationDegrees highestLongitude;
CLLocationDegrees lowestLongitude;
// Calculate the above variable values...
// These calculations would have to be more complex if you need to handle the fact that longitude values wrap
CLLocationDegrees latitudeDelta = highestLatitude - lowestLatitude;
CLLocationDegrees longitudeDelta = highestLongitude - lowestLongitude;
CLLocationCoordinate2D center = CLLocationCoordinate2DMake(lowestLatitude + (latitudeDelta / 2.0f), lowestLongitude + (longitudeDelta / 2.0f));
MKCoordinateSpan span = MKCoordinateSpanMake(latitudeDelta, longitudeDelta);
MKCoordinateRegionMake(center, span);