2
I have a page that calculates the distance between the Point A and the Point B, but I need to compute tolls on this route.
I think of having a bank with the coordinates (lat and lng) of the toll and check if it exists on the route, but do not know how to.
I need to return the amount of tolls and values of them in the interval Point A - Point B. Any help will be valid.
Javascript:
var options = {
componentRestrictions: {country: 'br'}
};
var source, destination;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
google.maps.event.addDomListener(window, 'load', function () {
new google.maps.places.Autocomplete(document.getElementById('txtSource'), options);
new google.maps.places.Autocomplete(document.getElementById('txtDestination'), options);
directionsDisplay = new google.maps.DirectionsRenderer({ 'draggable': true });
});
var mumbai = new google.maps.LatLng(-19.9166813, -43.9344931);
var mapOptions = {
zoom: 5,
center: mumbai
};
map = new google.maps.Map(document.getElementById('dvMap'), mapOptions);
function GetRoute() {
directionsDisplay.setMap(map);
//directionsDisplay.setPanel(document.getElementById('dvPanel'));
//*********DIRECOES E ROTAS**********************//
source = document.getElementById("txtSource").value;
destination = document.getElementById("txtDestination").value;
var request = {
origin: source,
destination: destination,
travelMode: google.maps.TravelMode.DRIVING
};
directionsService.route(request, function (response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
//*********DISTANCIA E DURACAO**********************//
var service = new google.maps.DistanceMatrixService();
service.getDistanceMatrix({
origins: [source],
destinations: [destination],
travelMode: google.maps.TravelMode.DRIVING,
unitSystem: google.maps.UnitSystem.METRIC,
avoidHighways: false,
avoidTolls: false
},
function (response, status) {
if (status == google.maps.DistanceMatrixStatus.OK && response.rows[0].elements[0].status != "ZERO_RESULTS") {
var distance = response.rows[0].elements[0].distance.text;
var duration = response.rows[0].elements[0].duration.text;
var dvDistance = document.getElementById("dvDistance");
dvDistance.innerHTML = "";
dvDistance.innerHTML += "Distancia: " + distance + "<br />";
dvDistance.innerHTML += "Duração:" + duration + "<br />";
} else {
alert("Não foi possível traçar essa rota.");
}
});
}
I need to calculate the toll values on the route, I searched and saw that only with the Google API this is not possible, so I think of using an external database with the location, price, etc. of tolls and cross-reference this information with the route of Google Maps. Thank you.
– J. Arc
@J. Arc therefore, it would take another database to have this data. At the moment, I don’t know any available for free use, but check this site here: http://www.abcr.org.br/TarifasPedagio/TarifaPedagio.aspx
– Gabriel Polidoro
Gabriel Polidoro, thank you so much for your help, I’m researching the subject.
– J. Arc