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 ...?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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
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.