googlemaps
Advanced tools
Comparing version 0.1.9 to 0.1.10
@@ -147,3 +147,4 @@ var qs = require('querystring'), | ||
// http://code.google.com/apis/maps/documentation/directions/ | ||
exports.directions = function(origin, destination, callback, sensor, mode, waypoints, alternatives, avoid, units, language) { | ||
// departureTime and arrivalTime must be passed as UNIX timestamp => Math.floor((new Date()).getTime()/1000) | ||
exports.directions = function(origin, destination, callback, sensor, mode, waypoints, alternatives, avoid, units, language, departureTime, arrivalTime) { | ||
var args = { | ||
@@ -154,2 +155,25 @@ 'origin': origin, | ||
if (mode) args.mode = mode; | ||
// for mode transit you MUST pass either departur or arrival time | ||
if (mode === 'transit' && ((typeof departureTime === "undefined" || departureTime === null) && (typeof arrivalTime === "undefined" || arrivalTime === null))) { | ||
var error = new Error('If you set the mode to "transit" you must also specify either a departure_time or an arrival_time'); | ||
if (typeof callback === 'funciton') { | ||
return callback(error); | ||
} | ||
else { | ||
throw error; | ||
} | ||
} | ||
if (typeof departureTime !== "undefined" && departureTime !== null) { | ||
if (mode === 'transit' || mode === 'driving') { | ||
args.departure_time = departureTime | ||
if (typeof arrivalTime !== "undefined" && arrivalTime !== null) { | ||
args.arrival_time = arrivalTime | ||
} | ||
} | ||
} | ||
if (waypoints) args.waypoints = waypoints; | ||
@@ -156,0 +180,0 @@ if (alternatives) args.alternatives = alternatives; |
{ | ||
"name": "googlemaps", | ||
"version": "0.1.9", | ||
"version": "0.1.10", | ||
"main": "./lib/googlemaps", | ||
@@ -5,0 +5,0 @@ "description": "A simple way to query the Google Maps API from Node.js", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22123
4
463
2