javascript 传单获取行车路线
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25838940/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
leaflet get driving directions
提问by sabas
Is there a way to get driving directions between two marker on a leaflet map? I am coding with javascript and using mapbox for layer. I can't find any methot or sth. Maybe it is not possible?
有没有办法在传单地图上的两个标记之间获取行车路线?我正在使用 javascript 编码并使用 mapbox 作为图层。我找不到任何方法或某事。也许这是不可能的?
回答by sabas
There are a couple of plugins which request directions from different providers, like this one https://github.com/Turistforeningen/leaflet-routing
有几个插件可以从不同的提供商那里请求方向,比如这个https://github.com/Turistforeningen/leaflet-routing
On plugins listing page there are another couple of them http://leafletjs.com/plugins.html
在插件列表页面上还有另外几个http://leafletjs.com/plugins.html
If you're using Mapbox, you can use Mapbox directions https://github.com/mapbox/mapbox-directions.js
如果您使用的是 Mapbox,则可以使用 Mapbox 方向https://github.com/mapbox/mapbox-directions.js
回答by Steve Bennett
You probably want to use OSRM, the Open Source Routing Machine. It's a static web application based on Leaflet that has a very fast routing interface. You obviously need to connect it to a routing server, but fortunately there is a free one available for car-based routing. Alternatively you can run your own.
您可能想使用OSRM,开源路由机器。它是一个基于 Leaflet 的静态 Web 应用程序,具有非常快速的路由接口。您显然需要将其连接到路由服务器,但幸运的是,有一个免费的可用于基于汽车的路由。或者,您可以运行自己的。
There's a demo at http://map.project-osrm.org/.