Fork me on GitHub

Leaflet Routing Machine

Easy, flexible routing for Leaflet

About Getting Started Tutorials API Download


Leaflet Routing Machine is an easy, flexible and extensible way to add routing to a Leaflet map. Using the default is just a few lines of code to add fully functional routing, but you can still customize almost every aspect of the user interface and interactions.


Getting started

Note: Leaflet Routing Machine v3.1.2 and later are compatible with Leaflet 1.0.0 (and release candidates), as well as Leaflet 0.7.

Getting started with Leaflet Routing Machine is easy. Include leaflet-routing-machine.css and leaflet-routing-machine.js in a Leaflet page:

<link rel="stylesheet" href="" />
<link rel="stylesheet" href="" />
<script src=""></script>
<script src=""></script>

(For production use, you might want to Download the files instead of using

If you prefer, you can also install using NPM:

npm install --save leaflet-routing-machine

To add the basic routing control to your map instance, use this Javascript code:

  waypoints: [
    L.latLng(57.74, 11.94),
    L.latLng(57.6792, 11.949)

Update 2020-04-06: The example above relies on OSRM's demo server. At this moment, the demo server (which is outside scope and control of the plugin's author) is no longer maintained, and its SSL certificate has expired. The plugin will not work unless you configure a routing backend yourself. I am sorry to say that, to my knowledge, there is no good default.

Note that in the most basic version, the control will not be able to do address lookups (geocoding), so you will have to provide the latitude and longitude of the waypoints. See the tutorials page for information about adding address lookup and much more. You might also want to dive into the API docs for details.

Help, problems and contributing

The plugin is free and open source. Leaflet Routing Machine is hosted on GitHub, where you can report issues or bugs.

Feedback and help is always welcome in any form: documentation, tutorials or code. Feel free to add a pull request. You can also try our community chat, the Leaflet Routing Machine gitter.

Copyright © 2015 Per Liedman, released under ISC License. Logo by Alexey Ivanov, released under Creative Commons CC-BY 3.0.

Sorry! The OSRM demo server appears down, or a network error occured.

This prevents Leaflet Routing Machine from displaying a route. The demo server will hopefully be back up soon. Please do not report this as an issue, Leaflet Routing Machine has no control over the demo server.

In production, set up your own OSRM instance, or pay a service provider.