0.0.0-gamma • Published 5 years ago

distances v0.0.0-gamma

Weekly downloads
8
License
MIT
Repository
github
Last release
5 years ago

distances Build Status

Google's distance matrix API

The Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations, based on the recommended route between start and end points.

Install

$ npm install distances

Usage

import distances from 'distances';

(async () => {
  const res = await distances({
    units: 'imperial',
    origins: 'Washington, DC',
    destinations: 'New + York + City, NY',
    key: 'GOOGLE_KEY',
  });
  console.log(res);
})();

You will get as response

{
  destination: [ 'New York, NY, USA' ],
  origin: [ 'Washington, DC, USA' ],
  distance: '226 mi',
  distanceValue: 363999,
  duration: '3 hours 50 mins',
  durationValue: 13777
}

Read more about in Google's Docs.

API

distances(params)

params

Type: object

Required parameters

origins: The starting point for calculating travel distance and time.

Type: string Examples:

  • Name: Washington, DC
  • Longitude and Latitude: 25.827200, -80.281500
destinations: One or more locations to use as the finishing point for calculating travel distance and time.

Type: string Examples:

  • Name: Washington, DC
  • Longitude and Latitude: 25.827200, -80.281500
key: Your application's API key. This key identifies your application for purposes of quota management. Get a key

Optional parameters

mode: Specifies the mode of transport to use when calculating distance.

Type: string Default: driving Travel modes: driving | walking | bicycling | transit

language: The language in which to return results.

Type: string

region: The region code, specified as a ccTLD (country code top-level domain) two-character value.

Type: string

avoid: Introduces restrictions to the route.

Type: string

units: Specifies the unit system to use when expressing distance as text.

License

MIT © Abraham Hernandez

0.0.0-gamma

5 years ago

0.0.0-beta

5 years ago

0.0.0-alpha

5 years ago

0.0.0-dev-1

5 years ago

0.0.0-dev

5 years ago

0.0.0

5 years ago