I have something like this:
How to display "549 km and 5 Stunden, 21 Minuten" from this json output in my website?
I have something like this:
How to display "549 km and 5 Stunden, 21 Minuten" from this json output in my website?
Something like this:
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix(
{
origins: ["Berlin"],
destinations: ["Frankfurt"],
travelMode: google.maps.TravelMode.DRIVING,
}, callback);
function callback(response, status) {
$("#result").text(response.rows[0].elements.distance.text + " and " + response.rows[0].elements.duration.text);
}
It looks fine to me but I haven't tested it so I may not be getting all the details right. I don't know how to get the result in German but this documentation may be helpful.
In place of $("#result")
, you need a selector or collection for the element where you want to show the result.