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