如何获得传单中两点之间最短路径的折线?

How to get a polyline for shortest path between two points in leaflet?

我是传单的新手,我需要为节点之间的最短路径创建一个。我还需要折线进行其他一些计算。 我尝试了一些插件,它们只在地图上显示最短路径,但不提供最佳路线的更多详细信息(多段线、点对点...)。 有什么办法可以获取数据吗?任何插件或技巧...?

您想使用一些地理编码(请参阅 http://leafletjs.com/plugins.html#geocoding ) to turn addresses into lat-lng coordinates, then route finding ( http://leafletjs.com/plugins.html#routing )来查找受街道网络约束的最短路径。

I tried some plugins which just display the shortest path on map but does not provide furthur details

那就不要使用路由插件,直接使用路由API(OSRM、GraphHopper、MapBox方向)。这显然会涉及更多工作,但您将拥有更好的控制权。