Socket
Socket
Sign inDemoInstall

google-distance-matrix

Package Overview
Dependencies
51
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 1.0.0

8

index.js

@@ -7,2 +7,4 @@ 'use strict';

var validModes = ['driving', 'walking', 'bicycling', 'transit'];
var GOOGLE_DISTANCE_API_URL = 'https://maps.googleapis.com/maps/api/distancematrix/json?',

@@ -83,3 +85,3 @@ SEPARATOR = '|',

GoogleDistanceMatrix.prototype.mode = function(mode) {
if (mode != 'driving' && mode != 'walking' && mode != 'bicycling') {
if (validModes.indexOf(mode) < 0) {
throw new Error('Invalid mode: ' + mode);

@@ -112,2 +114,6 @@ }

GoogleDistanceMatrix.prototype.arrival_time = function(arrival_time) {
this.options.arrival_time = arrival_time;
}
GoogleDistanceMatrix.prototype.key = function(key) {

@@ -114,0 +120,0 @@ delete this.options.client;

2

package.json
{
"name": "google-distance-matrix",
"version": "0.0.3",
"version": "1.0.0",
"description": "A Node.js wrapper for Google Maps Distance Matrix API",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,14 +0,14 @@

#Node.js wrapper for Google Distance Matrix API
# Node.js wrapper for Google Distance Matrix API
The Google Distance Matrix API is a service that provides travel distance and time for a matrix of origins and destinations. The information returned is based on the recommended route between start and end points, as calculated by the Google Maps API, and consists of rows containing duration and distance values for each pair.
Please refer to [Google Distance Matrix API](https://developers.google.com/maps/documentation/distancematrix/) documentation for further details on **request parameters** and **response format**.
Please refer to [Google Distance Matrix API](https://developers.google.com/maps/documentation/distancematrix/) documentation for further details on **request parameters** and **response format**.
Unlike similar modules, this one accepts multiple origins and the result data is just like the one returned by the Google API.
##Installation
## Installation
`npm install google-distance-matrix`
##Usage
## Usage
```javascript

@@ -23,7 +23,7 @@ var distance = require('google-distance-matrix');

console.log(distances);
}
})
```
##Parameters
## Parameters
###API Key
### API Key

@@ -37,3 +37,3 @@ Please read the [API Key](https://developers.google.com/maps/documentation/distancematrix/#api_key) documentation first.

1. Create an environment variable `GOOGLE_API_KEY`, or...
2. Programatically:
2. Programatically:
```javascript

@@ -46,3 +46,3 @@ distance.key('YOUR-API-KEY');

1. Create environment variables `GOOGLE_CLIENT_KEY` and `GOOGLE_SIGNATURE_KEY`, or...
2. Programmatically:
2. Programmatically:
```javascript

@@ -53,3 +53,3 @@ distance.client('YOUR-CLIENT-KEY');

###Options
### Options

@@ -86,3 +86,9 @@ Mode (optional): `driving | walking | bicycling`, default `driving`

###Origins
Arrival time (optional): desired time of arrival as seconds since midnight, January 1, 1970 UTC
```javascript
distance.arrival_time(1404696787);
```
### Origins
An array of one or more addresses and/or textual latitude/longitude values from which to calculate distance and time. If you pass an address as a string, the service will geocode the string and convert it to a latitude/longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

@@ -94,3 +100,3 @@ ```javascript

```
###Destinations
### Destinations
An array of one or more addresses and/or textual latitude/longitude values to which to calculate distance and time. If you pass an address as a string, the service will geocode the string and convert it to a latitude/longitude coordinate to calculate directions. If you pass coordinates, ensure that no space exists between the latitude and longitude values.

@@ -102,3 +108,3 @@ ```javascript

```
##Example
## Example

@@ -136,2 +142,2 @@ ```javascript

});
```
```

Sorry, the diff of this file is not supported yet

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