开发者

Objective C map view question

开发者 https://www.devze.com 2023-01-11 04:24 出处:网络
I have been working with the map view and came across these variables: span.longitudeDelta and span.latitudeDelta...They seem to ef开发者_运维知识库fect the amount of zoom of the screen(possibly by se

I have been working with the map view and came across these variables: span.longitudeDelta and span.latitudeDelta... They seem to ef开发者_运维知识库fect 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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号