I was wondering if you could please help me with an issue I am having with the google distance matrix api.
Please see my code below:
////////////////////////////////////////////////////////////////
var build = function (pc) {
var origin = "london";
var dest = pc;
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: [origin],
destinations: [dest],
travelMode: google.maps.TravelMode.DRIVING,
durationInTraffic: true,
avoidHighways: false,
unitSystem: google.maps.UnitSystem.METRIC,
avoidTolls: false
}, callback);
function callback(response, status) {
var distanceVal = response.rows[0].elements[0].distance.value;
return distanceVal;
}
};
////////////////////////////////////////////////////////////////
for (var i = 0; i < dealers.length; i++) {
var postcode = dealers[i].address[0].postcode;
var output = build(postcode);
console.log(output);
}
///////////////////////////////////////////////////////////////////////////
When it writes to the console I would like to see the different values that are returned from the google api. For some reason it doesn't seem to return anything
Thanks in advance