Objective C 地图查看问题

发布于 2024-09-13 13:31:44 字数 261 浏览 3 评论 0原文

我一直在使用地图视图并遇到这些变量:span.longitudeDelta 和 span.latitudeDelta ...它们似乎会影响屏幕的缩放量(可能通过设置窗口的 x/y 来实现?)谁能告诉我这些值的作用是什么以及它们与屏幕宽度/高度(以纬度/经度为单位)有何关系?

感谢您抽出时间。

编辑:我想知道这个,因为我试图弄清楚我的屏幕正在查看的纬度和长度是多少度......示例:如果我缩小屏幕的最左侧可能是 34.533,右侧可能是 34.533边可能是 39.324。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜嗑 2024-09-20 13:31:44

你的想法是正确的。这些值是地图视图的宽度和高度(以度为单位),以地图中心点为中心。

map.region 是您可以读取或设置的 MKCooperativeRegion。 MKCoordinateRegion 是一个具有两个字段的结构:center 和 span。 map.region.center 是一个 CLLocation2D 结构(有两个字段,纬度和经度),map.region.span 是一个 MKCooperativeSpan 结构,其中包含您提到的字段。

如果要设置地图以显示给定区域,请创建一个 MKCooperativeRegion,设置属性,然后确保该区域适合地图的大小:

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

屏幕的左边缘是(粗略地说,因为经度线不是平行线):

float leftEdgeLongitude = map.region.center.longitude - (map.region.span.longitudeDelta / 2);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文