camerican / Help-Desk

Help Desk for NYCDA Projects
1 stars 1 forks source link

Travel time #7

Closed Kharmon94 closed 7 years ago

Kharmon94 commented 7 years ago

Code is not throwing an error but also is not displaying so im stuck im sure im close

function TravelTime() {
    var service = new google.maps.DistanceMatrixService();
    service.getDistanceMatrix(
  {
    arrivalTime: Date,
    departureTime: Date, 
  })
}
}
document.addEventListener("DOMContentLoaded",function(){
    initMap();
    calcRoute();
    document.getElementById("search").addEventListener("submit",function(event){
        event.preventDefault();
        calcRoute();
        TravelTime();
    });
});
camerican commented 7 years ago

We were able to solve this by changing the object passed into getDistanceMatrix. The original call above was passing through the expected return parameters. By passing in the correct input parameters, we were then able to provide a callback. From inside the callback, we were able to delve into the response (1st parameter) and update a DOM element with the desired distance and time data.