如何在小册子中的两点之间获得最短路径的折线? [英] How to get a polyline for shortest path between two points in leaflet?
问题描述
我是传单的新手,我需要为节点之间的最短路径创建一个图层.我还需要折线进行其他一些计算. 我尝试了一些插件,这些插件仅在地图上显示最短路径,但没有提供进一步的详细信息(折线,点对点...)以获取最佳路线. 有什么办法可以获取数据?任何插件或技巧...?
I am new in leaflet and I need to create a layer for shortest path between nodes. I also need the polyline for some other calculations. I tried some plugins which just display the shortest path on map but does not provide furthur details(polyline, point-to-point ...) for the optimal route. Is there any way that I can get the data? any plugin or trick ...?
推荐答案
您要使用一些地理编码(请参见 http://leafletjs.com/plugins.html#geocoding )将地址转换为经纬度坐标,然后进行路由查找( http://leafletjs.com/plugins.html#routing )以查找受街道网络约束的最短路径.
You want to use some geocoding (see http://leafletjs.com/plugins.html#geocoding ) to turn addresses into lat-lng coordinates, then route finding ( http://leafletjs.com/plugins.html#routing ) to find the shortest path constrained by a street network.
我尝试了一些仅在地图上显示最短路径但不提供详细信息的插件
I tried some plugins which just display the shortest path on map but does not provide furthur details
然后,不要使用路由插件,而直接使用路由API(OSRM,GraphHopper,MapBox方向).显然它将涉及更多的工作,但您将拥有更好的控制.
Then don't use a routing plugin and use the routing APIs (OSRM, GraphHopper, MapBox directions) directly. It will obviously involve more work but you will have a finer control.
这篇关于如何在小册子中的两点之间获得最短路径的折线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!