获取 iphone 地图套件位置之间的所有坐标
谁能告诉我如何获取位置之间的所有纬度、经度值...??? 作为实现的一部分,我希望拥有起点和终点之间的所有纬度、经度值来绘制路线。
提前致谢...
Can anyone tell me how to get all Lat,Long values between to locations...???
As part of implementation I would like to have all the Lat,Long values between the start end end point to draw the route.
Thanks in advance...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
找到这些点非常简单,不需要任何聪明的三角学。请注意,如果点之间的距离需要是特定的距离(例如每 100 米),则需要三角学。不过,我们将制作简单版本。
基本上,您可以计算出纬度之间的差异和经度之间的差异,决定需要多少个点(如上所述,“全部”是一个无限数),将距离除以点数,然后迭代它们。 (注意:我还没有测试过这段代码,但你应该能够明白。)
Finding the points is pretty straightforward and doesn't require any clever trigonometry. Note that if the distance between points needs to be a specific amount -- say every 100 meters -- then trigonometry will be required. We'll do the simple version, though.
Basically you figure out the difference between the latitudes and the difference between the longitudes, decide how many points you want (as noted, "all" is an infinite number), divide the distance by the number of points, and iterate through them. (Note: I haven't tested this code, but you should be able to get the idea.)
你所说的“全部”是什么意思?由于纬度/经度对是双精度的,因此您正在谈论无限多个点。
如果你想在两点之间画一条线,你可以使用 CAShapeLayer 在地图上画一条线来连接它们。
然而,“路线”一词意味着您想知道沿着道路行驶的点。再说一遍,你真正要求的是什么?人们可以驾驶的路线?走?坐公交车吗? MapKit 本身根本无法帮助您进行路由,您必须查看其他第三方框架。
What do you mean by "all"? Since lat/long pairs are doubles, you are talking about an infinite number of points.
If you want to draw a line between two points you can use a CAShapeLayer to draw a line on the map to connect them.
The word "route" however impies you want to know points that travel along a road. There again, what are you really asking for? Routes people could drive? Walk? Take a bus? MapKit itself does not help you with routing at all, you would have to look at other third party frameworks.