https://github.com/project-osrm/osrm.js
REST client for the OSRM server API
https://github.com/project-osrm/osrm.js
Last synced: 11 months ago
JSON representation
REST client for the OSRM server API
- Host: GitHub
- URL: https://github.com/project-osrm/osrm.js
- Owner: Project-OSRM
- License: bsd-2-clause
- Created: 2015-02-18T22:48:24.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-05-27T08:22:17.000Z (almost 5 years ago)
- Last Synced: 2024-05-22T08:45:19.716Z (almost 2 years ago)
- Language: JavaScript
- Size: 1.71 MB
- Stars: 61
- Watchers: 20
- Forks: 33
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# osrm.js
[](https://travis-ci.org/Project-OSRM/osrm.js)
Client library for [Open Source Routing Machine - OSRM](https://github.com/Project-OSRM/osrm-backend) that uses the REST http API
that is exposed by ```osrm-routed```.
The interface is compatible with [node-osrm](https://github.com/Project-OSRM/node-osrm). However it is not meant as
replacement for ```node-osrm``` on the server.
Can be used with NodeJS and with browserify.
# Example
```js
var OSRM = require('osrm.js');
var osrm = new OSRM("https://router.project-osrm.org");
osrm.route({
coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
steps: true,
alternatives: false,
overview: 'simplified',
geometries: 'polyline'
}, function(err, result) {
console.log(result);
});
osrm.trip({
coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
steps: true,
overview: 'simplified',
geometries: 'polyline'
}, function(err, result) {
console.log(result);
});
osrm.match({
coordinates: [[13.438640,52.519930], [13.415852,52.513191]],
timestamps: [1460585940, 1460585945],
steps: true,
overview: 'simplified',
geometries: 'polyline'
}, function(err, result) {
console.log(result);
});
osrm.table({
coordinates: [[13.438640,52.519930], [13.415852,52.513191], [13.333086, 52.4224]],
sources: [0],
destinations: [1, 2]
}, function(err, result) {
console.log(result);
});
osrm.tile([17603, 10747, 15], function(err, result) {
console.log(result); // pbf encoded vector tile
});
//You can also pass it query paths directly:
osrm.request('/route/v1/driving/13.438640,52.519930;13.415852,52.513191', function(err, result) {
});
```
# Testing
```
npm test # run node tape tests
firefox test.html # check the console if tape tests worked
```