Node.js wrapper for the Goople Distance Matrix API.
The motivation with this module is to provide a wrapper over google distance matrix api in node js.
Install Distance Matrix API v2:
npm i distance-matrix-2
or
yarn add distance-matrix-2
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);
- Overrides the current google api key.
-
Get the result from the google distance matrix api.
-
The available options can be found in the google distance matrix api docs.
-
Updated version of some distance matrix apis.
-
Version 1.0.0 is broken, don't use it.
MIT