Created
January 25, 2012 02:07
-
-
Save mackato/1674171 to your computer and use it in GitHub Desktop.
Check MKMapView contains CLLocationCoordinate2D
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MKCoordinateRegion region = mapView.region; | |
CLLocationCoordinate2D topLeftCoordinate = | |
CLLocationCoordinate2DMake(region.center.latitude + (region.span.latitudeDelta / 2.0), | |
region.center.longitude - (region.span.longitudeDelta / 2.0)); | |
CLLocationCoordinate2D bottomRightCoordinate = | |
CLLocationCoordinate2DMake(region.center.latitude - (region.span.latitudeDelta / 2.0), | |
region.center.longitude + (region.span.longitudeDelta / 2.0)); | |
MKMapPoint topLeftMapPoint = MKMapPointForCoordinate(topLeftCoordinate); | |
MKMapPoint bottomRightMapPoint = MKMapPointForCoordinate(bottomRightCoordinate); | |
MKMapRect mapRect = MKMapRectMake(topLeftMapPoint.x, topLeftMapPoint.y, | |
fabs(bottomRightMapPoint.x - topLeftMapPoint.x), fabs(bottomRightMapPoint.y - topLeftMapPoint.y)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment