https://github.com/perliedman/lrm-osrm4
Leaflet Routing Machine plugin with support for OSRM version 4
https://github.com/perliedman/lrm-osrm4
Last synced: over 1 year ago
JSON representation
Leaflet Routing Machine plugin with support for OSRM version 4
- Host: GitHub
- URL: https://github.com/perliedman/lrm-osrm4
- Owner: perliedman
- License: isc
- Created: 2017-03-10T16:02:52.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-03-10T16:05:14.000Z (over 9 years ago)
- Last Synced: 2025-03-01T19:20:21.596Z (over 1 year ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Leaflet Routing Machine / OSRM 4
================================
[](https://www.npmjs.com/package/lrm-osrm4)
Extends [Leaflet Routing Machine](https://github.com/perliedman/leaflet-routing-machine) with support for [OSRM](https://graphhopper.com/)'s old major version, OSRM 4; Leaflet Routing Machine has built-in support for OSRM 5.
Some brief instructions follow below, but the [Leaflet Routing Machine tutorial on alternative routers](http://www.liedman.net/leaflet-routing-machine/tutorials/alternative-routers/) is recommended.
## Installing
Go to the [releases page](https://github.com/perliedman/lrm-osrm4/releases) to get the script to include in your page. Put the script after Leaflet and Leaflet Routing Machine has been loaded.
To use with for example Browserify:
```sh
npm install --save lrm-osrm4
```
## Using
There's a single class exported by this module, `L.Routing.OSRM4`. It implements the [`IRouter`](http://www.liedman.net/leaflet-routing-machine/api/#irouter) interface. Use it to replace Leaflet Routing Machine's default OSRM 5 router implementation:
```javascript
var L = require('leaflet');
require('leaflet-routing-machine');
require('lrm-osrm4'); // This will tack on the class to the L.Routing namespace
L.Routing.control({
router: L.routing.osrm4('http://your-osrm-url'),
}).addTo(map);
```
Note that you will need to set up your own OSRM4 server: OSRM's demo server is running OSRM 5.