Skip to content

Instantly share code, notes, and snippets.

@mackato
Created January 25, 2012 02:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mackato/1674171 to your computer and use it in GitHub Desktop.
Save mackato/1674171 to your computer and use it in GitHub Desktop.
Check MKMapView contains CLLocationCoordinate2D
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