user3802409
user3802409

Reputation:

leaflet: get driving directions

Is there a way to get driving directions between two markers on a leaflet map? I am coding with javascript and use mapbox for layers. I can't find any method or sth.

Is this possible?

Upvotes: 8

Views: 31448

Answers (2)

sabas
sabas

Reputation: 743

There are a couple of plugins which request directions from different providers, like this one https://github.com/Turistforeningen/leaflet-routing

On plugins listing page there are another couple of them http://leafletjs.com/plugins.html

If you're using Mapbox, you can use Mapbox directions https://github.com/mapbox/mapbox-directions.js

Upvotes: 10

Steve Bennett
Steve Bennett

Reputation: 126205

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.

There's a demo at http://map.project-osrm.org/ .

Upvotes: 9

Related Questions