Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Allow departure_time argument for directions. #27

Closed
wants to merge 1 commit into from

3 participants

@bockmabe

This just allows for the addition of departure_time argument. In the case of mode set to 'transit', if no departure_time is specified google returns an error. e.g. http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&mode=transit returns

{
"routes" : [],
"status" : "INVALID_REQUEST"
}

Where as, http://maps.googleapis.com/maps/api/directions/json?origin=Brooklyn&destination=Queens&sensor=false&departure_time=1343605500&mode=transit returns a proper answer.

@grobot

If it fails with no departure time, can we add in a sane default, like setting departure time to now?

@bockmabe
@grobot

Yes. That would be great.

@fabriziomoscon
Collaborator

@bockmabe I added the arrivalTime as well in this PR https://github.com/moshen/node-googlemaps/pull/43/files
Worth checking, but one of these 2 PR must be merged

@bockmabe

@fabriziomoscon, thanks your PR looks good and addresses the requests I got on this one.

@bockmabe bockmabe closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 31, 2013
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 1 deletion.
  1. +2 −1  lib/googlemaps.js
View
3  lib/googlemaps.js
@@ -128,7 +128,7 @@ exports.reverseGeocode = function(latlng, callback, sensor, language ) {
};
// http://code.google.com/apis/maps/documentation/distancematrix/
-exports.distance = function(origins, destinations, callback, sensor, mode, alternatives, avoid, units, language) {
+exports.distance = function(origins, destinations, callback, sensor, mode, alternatives, avoid, units, language, departure_time) {
var args = {
'origins': origins,
'destinations': destinations
@@ -137,6 +137,7 @@ exports.distance = function(origins, destinations, callback, sensor, mode, alter
if (avoid) args.avoid = avoid;
if (units) args.units = units;
if (language) args.language = language;
+ if (departure_time) args.departure_time = departure_time;
args.sensor = sensor || 'false';
var path = '/maps/api/distancematrix/json';
Something went wrong with that request. Please try again.