Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get TopLeft and BottomRight from MKCoordinateRegion MKMapView

I checked the properties in documentation for MKCoordinateRegion, MKCoordinateSpan and MKMapView to see there is a way to get the TopLeft and BottomRight Lat Long from the map view and I didn't find any. I know that the span gives me the Lat long delta but is there a way to get the actual TopLeft and BottomRight lat longs from map view without having to do weird calculations?

I found this.

Not sure if that is accurate enough. Any votes for that?

like image 825
Dave Avatar asked Mar 17 '10 18:03

Dave


1 Answers

I don't think these calculations qualify as weird:

CLLocationCoordinate2D center = region.center;
CLLocationCoordinate2D northWestCorner, southEastCorner;
northWestCorner.latitude  = center.latitude  + (region.span.latitudeDelta  / 2.0);
northWestCorner.longitude = center.longitude - (region.span.longitudeDelta / 2.0);
southEastCorner.latitude  = center.latitude  - (region.span.latitudeDelta  / 2.0);
southEastCorner.longitude = center.longitude + (region.span.longitudeDelta / 2.0);
like image 50
Ole Begemann Avatar answered Oct 04 '22 17:10

Ole Begemann