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.
node-distance-matrix
Advanced tools
Readme
A distance matrix package that consumes Google Distance Matrix API to get distances between locations
Install the package using:
npm install node-distance-matrix --save
Require and initialize the package using:
NodeDistanceMatrix = require('node-distance-matrix);
Access the getDistanceMatrix
method using
const distanceMatrix = NodeDistanceMatrix.getDistanceMatrix(apiKey, origin, destination, mode, unitType);
Access the getDistanceMatrixWithTraffic
method using
const distanceMatrixWithTraffic = NodeDistanceMatrix.getDistanceMatrixWithTraffic(apiKey, origin, destination, departure_time, unitType);
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.
departure_time is a date integer in seconds since midnight, January 1, 1970 UTC
unitType is the unit for calculating the distance matrix, it can be imperial (default), or metric.
Access the distance data using a thenable:
distanceMatrix.then(response => { console.log(response.data) });
const mockDistanceMatrix = NodeDistanceMatrix.getMockDistanceMatrix();
Then,
mockDistanceMatrix.then(response => { console.log(response.data) });
To access the distance matrix using async/await method, use the folowing method.
import DistanceMatrix from 'node-distance-matrix';
const getDistanceMatrix = async () => {
const distanceMatrix = await DistanceMatrix.getDistanceMatrix(apikey, origin, destination);
console.log(distanceMatrix.data);
}
To access the distance matrix with traffic data, specify a departure_time as an integer in seconds. We use the getDistanceMatrixWithTraffic
method.
import DistanceMatrix from 'node-distance-matrix';
const dateInteger = Date.parse('November 1, 2020');
const getDistanceMatrixWithTraffic = async () => {
const distanceMatrixWithTraffic = await DistanceMatrix.getDistanceMatrixWithTraffic(apikey, origin, destination, dateInteger);
console.log(distanceMatrixWithTraffic.data);
}
FAQs
A node distance matrix package that consumes Google Distance Matrix API to get distances between locations
The npm package node-distance-matrix receives a total of 102 weekly downloads. As such, node-distance-matrix popularity was classified as not popular.
We found that node-distance-matrix 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.