good evening, I have an issue when using the routes API to calculate tolls for a route. I initially used the places API for autocomplete, but I’m unsure how to implement the routes API to achieve the toll calculation.
I found a way to do it, storing in a variable called ‘toolcost’ the total toll fees, but I couldn’t make it work; it’s the part of the comment where it says ‘here’
var request = {
origin: document.getElementById("from").value,
destination: document.getElementById("to").value,
travelMode: google.maps.TravelMode.DRIVING, //WALKING, BYCYCLING, TRANSIT
unitSystem: google.maps.UnitSystem.IMPERIAL
}
//pass the request to the route method
directionsService.route(request, function (result, status) {
if (status == google.maps.DirectionsStatus.OK) {
//HEREEEEEE
let tollCost = 0;
for (const step of request.steps) {
if (step.toll) {
tollCost += step.toll.amount;
}
}