0
要使用接受northEast和SouthWest坐标的各种API用作“视口”,某些API对于搜索具有最大平方英里限制。MKMapView - 如何计算当前正在查看的平方英里
我想计算当前MKMapView缩放级别显示的平方英里数。
要使用接受northEast和SouthWest坐标的各种API用作“视口”,某些API对于搜索具有最大平方英里限制。MKMapView - 如何计算当前正在查看的平方英里
我想计算当前MKMapView缩放级别显示的平方英里数。
这里是解决方案:
- (float)numSquareMiles
{
CLLocationCoordinate2D northEast, southWest;
northEast = [mapView convertPoint:CGPointMake(mapView.frame.size.width, 0) toCoordinateFromView:mapView];
southWest = [mapView convertPoint:CGPointMake(0, mapView.frame.size.height) toCoordinateFromView:mapView];
float distanceLatInDegrees = northEast.latitude - southWest.latitude;
float numLatMiles = 69.172 * distanceLatInDegrees;
float distanceLonInDegrees = northEast.longitude - southWest.longitude;
float numLonMiles = 69.172 * distanceLonInDegrees;
float numSquareMiles = numLatMiles*numLonMiles;
return numSquareMiles;
}