openrouteservice
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

Openrouteservice API for JavaScript/TypeScript

A type-safe solution to consume the Openrouteservice API

Please read the API documentation at Openrouteservice and grab an API key.

To use, just create an instance of the API and call your function:

import Openrouteservice from 'openrouteservice';
import { Profile } from 'openrouteservice/dist/common.js';
import { DirectionsFormat } from 'openrouteservice/dist/directions.js';

const ors = new Openrouteservice(API_KEY);
const directions = await ors.getDirections(
    Profile.DRIVING_CAR,
    DirectionsFormat.JSON,
    {
        coordinates: [
            [-121.86592918628558, 37.41513158647777],
            [-121.86597210162844, 37.424061505151634]
        ]
    }
);

console.log(directions);
console.log(
    directions.routes[0].geometry
        && 
    Openrouteservice.decodePolyline(directions.routes[0].geometry, true)
);

Readme

Keywords

Package Sidebar

Install

npm i openrouteservice

Weekly Downloads

4

Version

0.1.2

License

GPL-3.0

Unpacked Size

83.5 kB

Total Files

36

Last publish

Collaborators

  • brianhvo02