Example – Tolls with rates depending on origin and destination (Mexico)
This example is specific to routes in Mexico, where some highways have a closed toll system. On these highways, the amount at each toll booth will vary according to the origin and destination.
In these cases, in addition to the toll booth details, the API will return in the response all available rates for their respective sections.
In the following example, we have a route with a two-axle truck that passes through the Ruiz toll booth in Mexico.
{ "calculationMode": "THE_FASTEST", "points": [ { "siteId": "p1", "latitude": 21.952688, "longitude": -105.116793 }, { "siteId": "p2", "latitude": 21.950404, "longitude": -105.114812 } ], "toll": { "vehicleType": "TRUCK_WITH_TWO_DOUBLE_AXLES" } }
The response will be returned in JSON format.
As in the previous examples, tollCosts
shows the total value of tolls on the entire route. In each leg
an object tollCalculation
will be returned containing an object tolls
with the values and information of each toll on the corresponding stretch, and legTotalCost
which shows the total value of tolls on that stretch.
Inside each object at tolls
we will have the information for each toll, with the following differences:
price
– Normal toll value (in this case it will be the same as the first option Origin – Destination);conditions
– Array with all the toll’s conditional values. In the case of this example, we have the following information:billingsType
– Type of toll collection. Possible values: [NORMAL, TAG
];routes
– Stretch of origin and destination defined by the concessionaire responsible for the toll plaza. In this example we will have 3 options:Entronque San Blas - Rosamorada, Estación Yago - Rosamorada e Entronque San Blas - Estación Ruiz
value
– Value of the toll in local currency.
The full response is below:
{ "id": "63dbfdd4e52c9c19635a68bd", "clientId": "maplink", "totalDistance": 326, "totalNominalDuration": 14, "averageSpeed": 79.98, "tollCosts": 300.00, "legs": [ { "distance": 326, "nominalDuration": 14, "averageSpeed": 79.98, "points": "cs~dCdsq`S`DgCFGHGrGsF", "tollCalculation": { "tolls": [ { "id": "2296", "name": "Peaje - Ruíz", "address": "", "city": "Ruiz", "state": { "name": "Nayarit", "code": "Nayarit" }, "country": "México", "concession": "Tepic - Villa Unión", "direction": "SOUTH", "coordinates": { "latitude": 21.951853461673615, "longitude": -105.11594373835344 }, "serviceTypes": [], "price": 220.00, "conditions": [ { "billingsType": [ "NORMAL" ], "routes": [ "Entronque San Blas - Rosamorada" ], "value": 220.00 }, { "billingsType": [ "NORMAL" ], "routes": [ "Estación Yago - Rosamorada" ], "value": 170.00 }, { "billingsType": [ "NORMAL" ], "routes": [ "Entronque San Blas - Estación Ruiz" ], "value": 160.00 } ] } ], "legTotalCost": 220.00 } } ], "crossedBorders": [], "source": "MAPLINK" }