如何在mapkit中获取以像素为单位的米?

发布于 2024-08-16 07:19:50 字数 127 浏览 7 评论 0原文

我想测试 mapKit 并想制作自己的叠加层来显示我的位置的准确性。 如果我的缩放系数为例如 0.005,我周围的圆必须有哪个半径(如果我的精度例如为 500m)?

如果能得到一些帮助就太好了:)

非常感谢。

I wanted to test the mapKit and wanted to make my own overlay to display the accuracy of my position.
If i have a zoom factor of for example .005 which radius does my circle around me has to have(If my accuracy is for example 500m)?

Would be great to get some help :)

Thanks a lot.

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

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

发布评论

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

评论(3

南风起 2024-08-23 07:19:50

查看MKCooperativeSpan 的文档,它是地图的region 属性的一部分。纬度一度始终约为。 111 公里,因此将 latitudeDelta 转换为米,然后获取每像素的米数应该很容易。对于经度值来说,这并不那么容易,因为 1 度经度覆盖的距离在 111 公里(赤道)和 0 公里(两极)之间变化。

Look at the documentation for MKCoordinateSpan, which is part of the map's region property. One degree of latitude is always approx. 111 km, so converting the latitudeDelta to meters and then getting to the meters per pixel should be easy. For longitudinal values it is not quite so easy as the distance covered by one degree of longitude varies between 111 km (at the equator) and 0 km (at the poles).

吐个泡泡 2024-08-23 07:19:50

我获得每像素米的方法:

MKMapView *mapView = ...;
CLLocationCoordinate2D coordinate = ...;

MKMapRect mapRect = mapView.visibleMapRect;
CLLocationDistance metersPerMapPoint = MKMetersPerMapPointAtLatitude(coordinate.latitude);

CGFloat metersPerPixel = metersPerMapPoint * mapRect.size.width / mapView.bounds.size.width;

My way to get meters per pixel:

MKMapView *mapView = ...;
CLLocationCoordinate2D coordinate = ...;

MKMapRect mapRect = mapView.visibleMapRect;
CLLocationDistance metersPerMapPoint = MKMetersPerMapPointAtLatitude(coordinate.latitude);

CGFloat metersPerPixel = metersPerMapPoint * mapRect.size.width / mapView.bounds.size.width;
不语却知心 2024-08-23 07:19:50

为了补充另一个答案,一分钟的纬度差异对应于一海里:这就是海里的定义方式。因此,转换为法定英里,1 海里 = 1.1508 法定英里,即 6076.1 英尺或 1852 米。

当您转到经度时,地球周围的经度圈的大小随着纬度的增加而缩小,正如前面的答案中所述。正确的系数是

1 minute of longitude = (1852 meters)*cos(theta),

其中 theta 是纬度。

当然,地球并不是一个完美的球体,但上面的简单计算绝对不会偏差超过1%。

To add to another answer, a difference of one minute of latitude corresponds to one nautical mile: that's how the nautical mile was defined. So, converting to statute miles, 1 nautical mile = 1.1508 statue miles, or 6076.1 ft. or 1852 meters.

When you go to longitude, the size of the longitude circles around the Earth shrink as latitude increases, as was noted on the previous answer. The correct factor is that

1 minute of longitude = (1852 meters)*cos(theta),

where theta is the latitude.

Of course, the Earth is not a perfect sphere, but the simple calculation above would never be off by more than 1%.

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