views:

85

answers:

1

From an MKCoordinateRegion, how do I tell what the top of a mapview's visible area is? The MKCoordinateRegion will have a center point (coordinates). Do I then add the latitudeDelta to the center point latitude to find the top of the map? Or must the delta be split in half and each half added and subtracted against the center point latitude?

A: 

Split the delta in half and add/subtract. Like this (which finds both top, bottom, left and right):

double top, bottom, left, right;            // top=N, bottom=S, left=W, right=E
top = region.center.latitude + region.span.latitudeDelta/2;
bottom = region.center.latitude - region.span.latitudeDelta/2;
left = region.center.longitude - region.span.longitudeDelta/2;
right = region.center.longitude + region.span.longitudeDelta/2;
Jens Willy Johannsen