如何在mapkit中获取以像素为单位的米?
我想测试 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
查看
MKCooperativeSpan
的文档,它是地图的region
属性的一部分。纬度一度始终约为。 111 公里,因此将latitudeDelta
转换为米,然后获取每像素的米数应该很容易。对于经度值来说,这并不那么容易,因为 1 度经度覆盖的距离在 111 公里(赤道)和 0 公里(两极)之间变化。Look at the documentation for
MKCoordinateSpan
, which is part of the map'sregion
property. One degree of latitude is always approx. 111 km, so converting thelatitudeDelta
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).我获得每像素米的方法:
My way to get meters per pixel:
为了补充另一个答案,一分钟的纬度差异对应于一海里:这就是海里的定义方式。因此,转换为法定英里,1 海里 = 1.1508 法定英里,即 6076.1 英尺或 1852 米。
当您转到经度时,地球周围的经度圈的大小随着纬度的增加而缩小,正如前面的答案中所述。正确的系数是
其中 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
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%.