The main requirement is to find travel time with traffic data between two locations or zip-code.
Inputs parameters would be from Location, destination, arrival time(this is between 6AM 8AM), mode of transportation, traffic model
Based on the above input parameters in my google script function it should return travel time
Can the below code modified for this requirement ?
function GetDuration(location1, location2, mode) {
var directions = Maps.newDirectionFinder()
.setOrigin(location1)
.setDestination(location2)
.setMode(Maps.DirectionFinder.Mode[mode])
.getDirections();
return directions.routes[0].legs[0].duration.text;
}
//directions from Times Sq to Central Park, NY
Logger.log(GetDuration("40.7591017,-73.984488","40.7670973,-73.9793693","DRIVING") )
From To Mode Distance
Central Park, NY Times Sq TRANSIT 8 mins