Socket
Socket
Sign inDemoInstall

node-distance-matrix

Package Overview
Dependencies
5
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-distance-matrix

A node distance matrix package that consumes Google Distance Matrix API to get distances between locations


Version published
Weekly downloads
11
decreased by-26.67%
Maintainers
1
Install size
375 kB
Created
Weekly downloads
 

Readme

Source

node-distance-matrix

A distance matrix package that consumes Google Distance Matrix API to get distances between locations

How To Use

Install the package using:

npm install node-distance-matrix --save

Require and initialize the package using:

  • const NodeDistanceMatrix = require('node-distance-matrix);

Access the getDistanceMatrix method using

  • const distanceMatrix = NodeDistanceMatrix.getDistanceMatrix(apiKey, origin, destination, mode);

apiKey is the google console key for your project.

origin is the start location for the distance, which can be an address or a latitude/longitude, it can also be an array of locations.

destination is the end location, which can be an address or a latitude/longitude, it can also be an array of locations.

mode is the mode of transportation, it can be driving (default), walking or bicycling.

Access the distance data using a thenable:

distanceMatrix.then(response => { console.log(response) });

To access the sample response for the locations, use:

const mockDistanceMatrix = NodeDistanceMatrix.getMockDistanceMatrix();

Then,

mockDistanceMatrix.then(response => { console.log(response) });

Author:

Ethan Nwankwo

Keywords

FAQs

Last updated on 25 Oct 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc