1.1.0 • Published 2 years ago

distance-matrix-2 v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Version License test

Distance Matrix API v2

Node.js wrapper for the Goople Distance Matrix API.

About

The motivation with this module is to provide a wrapper over google distance matrix api in node js.

Getting Started

Install Distance Matrix API v2:

npm i distance-matrix-2

or

yarn add distance-matrix-2

Example:

When creating a new instance of the distance matrix service, you can optionally pass an API key.

  • Connection status.
import { DistanceMatrixService } from "distance-matrix-2";

// You can pass the api key via constructor.
const service = new DistanceMatrixService(process.env.API_KEY);

// Also using the setKey method.
service.setKey(process.env.API_KEY);

const res = await service.getDistanceMatrix({ ...options });

console.log(res.status);
console.log(res.destination_addresses);
console.log(res.origin_addresses);
console.log(res.rows);

API

.setKey( key )

  • Overrides the current google api key.

.getDistanceMatrix( options )

Notes

  • Updated version of some distance matrix apis.

  • Version 1.0.0 is broken, don't use it.

Licence

MIT