views:

55

answers:

1

Hello,

I have been working with the map view and came across these variables: span.longitudeDelta and span.latitudeDelta... They seem to effect the amount of zoom of the screen(possibly by setting the window's x/y?) Can anyone tell me what these values do and how they relate to the screens width/height in degrees of lat/long?

Thank you for your time.

Edit: I am wondering this because I am trying to figure out what degrees of lat and long my screen is looking at.... Example: if I am zoomed way out the very left hand side of my screen could be 34.533 and the right side could be 39.324.

+1  A: 

You have the right idea. These values are the width and height of the map view in degrees, centered on the map's center point.

map.region is an MKCoordinateRegion that you can read or set. MKCoordinateRegion is a struct with two fields: center and span. map.region.center is a CLLocation2D struct (which has two fields, latitude and longitude) and map.region.span is an MKCoordinateSpan struct with the fields you mentioned.

If you want to set a map to show a given area, create an MKCoordinateRegion, set the properties, then make sure that the region fits the size of your map with:

MKCoordinateRegion scaledRegion = [map regionThatFits:region];
[map setRegion:scaledRegion animated:NO];

The left edge of your screen is (roughly, since longitude lines are not parallel):

float leftEdgeLongitude = map.region.center.longitude - (map.region.span.longitudeDelta / 2);
Seamus Campbell
Thank you for the very good response.
Dave C