Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
google-distance-ssrf-fixed
Advanced tools
Readme
Easily get traveling distance and duration data between locations with the Google Distance Matrix API
npm install google-distance
var distance = require('google-distance');
distance.get(
{
origin: 'San Francisco, CA',
destination: 'San Diego, CA'
},
function(err, data) {
if (err) return console.log(err);
console.log(data);
});
The above example outputs the following data
object:
{
index: null,
distance: '807 km',
distanceValue: 807366,
duration: '7 hours 30 mins',
durationValue: 26981,
origin: 'San Francisco, CA, USA',
destination: 'San Diego, CA, USA',
mode: 'driving',
units: 'metric',
language: 'en',
avoid: null,
sensor: false
}
This example will return an array of data
objects corresponding to all origin/destination pairs.
distance.get(
{
origins: ['San Francisco, CA','San Diego, CA'],
destinations: ['San Diego, CA','Seattle, WA']
},
function(err, data) {
if (err) return console.log(err);
console.log(data);
});
Result:
Origin | Destination |
---|---|
San Francisco, CA | San Diego, CA |
San Francisco, CA | Seattle, WA |
San Diego, CA | San Diego, CA |
San Diego, CA | Seattle, WA |
Here is a full list of options you can include to tailor your query:
name
(eg. 'San Francisco, CA'
) | latitude/longitude
(eg. '51.510652,-0.095444'
)null
(default) | specify an index for identification'driving'
(default) | 'walking'
| 'bicycling'
'metric'
(default) kilometers/meters | 'imperial'
miles/feet'en'
(default) | more languagesnull
(default) | 'highways'
| 'tolls'
false
(default) | true
| determines if GPS is used to find user locationNote: The units
setting only affects the text displayed within distance
fields.
distanceValue
is always in meters, and durationValue
is always in seconds.
This example specifies mode
and units
:
distance.get(
{
origin: 'San Francisco, CA',
destination: 'Los Angeles, CA',
mode: 'bicycling',
units: 'imperial'
},
function(err, data) {
if (err) return console.log(err);
console.log(data);
});
Outputs:
{
index: null,
distance: '499 mi',
distanceValue: 802534,
duration: '1 day 21 hours',
durationValue: 161896,
origin: 'San Francisco, CA, USA',
destination: 'Los Angeles, CA, USA',
mode: 'bicycling',
units: 'imperial',
language: 'en',
avoid: null,
sensor: false
}
Let's use latitude and longitude for our origin/destination and an index:
distance.get(
{
index: 1,
origin: '37.772886,-122.423771',
destination: '37.871601,-122.269104'
},
function(err, data) {
if (err) return console.log(err);
console.log(data);
});
Outputs:
{
index: 1,
distance: '21.9 km',
distanceValue: 21946,
duration: '21 mins',
durationValue: 1251,
origin: 'Octavia Boulevard, San Francisco, CA 94102, USA',
destination: '2066-2070 University Avenue, Berkeley, CA 94704, USA',
mode: 'driving',
units: 'metric',
language: 'en',
avoid: null,
sensor: false
}
Using an API key is not required, but recommended since you can track your usage and make sure you don't exceed Google's quota. You can request a key by following these steps.
Specify an API key for use like this:
var distance = require('google-distance');
distance.apiKey = 'API_KEY';
Business users can omit the API key and instead specify their business client and signature keys:
var distance = require('google-distance');
distance.businessClientKey = 'CLIENT_KEY';
distance.businessSignatureKey = 'SIGNATURE_KEY';
Install the development dependencies:
npm install
Run the tests:
npm test
FAQs
A simple node.js wrapper for Google's Distance Matrix API
The npm package google-distance-ssrf-fixed receives a total of 0 weekly downloads. As such, google-distance-ssrf-fixed popularity was classified as not popular.
We found that google-distance-ssrf-fixed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.