One lib to route them all : RoutingJS is a promise-based web client for accessing different routing web services, analogous to our Python client routingpy. Get unified access to several routing services with the power of modern asynchronous JavaScript fully typed thanks to the power of TypeScript!
We currently support the following routers:
Future support for other service (like the ones routingpy is supporting) might come at a later stage.
Router clients are installable individually:
npm install @routingjs/valhalla
RoutingJS offers directions
, matrix
and reachability
methods where available (e.g. OSRM does not support reachability/isochrones).
import { Valhalla } from "@routingjs/valhalla" const v = new Valhalla() // URL defaults to http://valhalla1.openstreetmap.de v.directions( [ [47.380742, 8.512516], // pass as [lat, lon] [47.359467, 8.557835], ], "auto" ).then((d) => { // do stuff with the directions response d.directions.forEach((direction) => { console.log(direction.feature) // get the route as GeoJSON feature console.log(direction.feature.properties.distance) // get the route distance console.log(direction.feature.properties.duration) // get the route duration }) }) v.reachability([47.380742, 8.512516], "pedestrian", [30, 90]).then((i) => { i.isochrones.forEach((isochrone) => { console.log(i.interval) // 30/90 console.log(i.intervalType) // "time" console.log(i.feature) // GeoJSON feature }) }) v.matrix( [ [47.380742, 8.512516], // pass as [lat, lon] [47.359467, 8.557835], ], "auto" ).then((m) => { console.log(m.durations) // get the durations array for each location console.log(m.distances) // get the distances array for each location })
See here for the full documentation.
Contributions are welcome! We are open to improvements of existing clients, as well as additions of new ones :-)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4