When you are computing a route or a route matrix, you might want to take into consideration any toll fees on the route. For select cities, you can compute the estimated toll fee for a route in the appropriate currency.
For the list of supported toll locations, see the reference for TollPass.
How tolls are calculated
The Routes API calculates the estimated toll fee, taking into consideration any toll price discounts or passes available to the driver or vehicle, and the most convenient payment methods. If there is no available toll price for a given route, the Routes API indicates the existence of a toll with an unknown fee.
To get accurate toll estimates, make sure you include the following information in your request:
- The emission type of the vehicle used for the route
(
VehicleEmissionType
). If no emission type is provided, the toll for a gasoline-fueled vehicle is returned. - All toll passes the vehicle and driver have using
tollPasses
. The API uses the toll passes to determine accurate toll fees, and returns cash prices when toll passes in the request are not local to the route. - Specify avoid tolls, if needed. If you want to avoid toll roads where
possible, add
avoidTolls
as aRouteModifier
.
Calculate tolls using a toll pass
To calculate tolls using a toll pass, you specify any toll passes as part of the request. The API then returns pass prices.
- If you specify an invalid toll pass, the pass is ignored.
- If specify multiple toll passes as an array, the API attempts to calculate the price for the route for each pass.
The way toll passes behave can vary by region.
- Rates may be lower with a toll pass: In some regions, a driver or vehicle with a toll pass pays a different toll than those who don't have a pass. For example, if you have a Good To Go! toll pass in Seattle, WA, US, you pay a lower toll than if you don't have a pass.
- Some roads may require a toll pass: Some regions, such as Indonesia, have roads that require a toll pass. If you don't specify a toll pass for a route where a toll pass is required, the API does not return a toll price.
Calculate toll fees for a route
To calculate toll fees for a route take the following steps:
- Set the
extraComputations
property toTOLLS
. - Specify the vehicle type and the toll pass type by using the
routeModifiers
property. - To calculate toll fees for an entire route, request
travelAdvisory
in thefields
property of the request; view the toll info for the entire route by readingroute.travelAdvisory.tollInfo
. - To calculate toll fees for individual legs of a route, request
legs
in thefields
property of the request; view the toll info for each leg by readingroute.legs[i].travelAdvisory.tollInfo
.
Example
The following example request shows how to request toll fees for a route:
const requestWithTolls = { origin: 'Kirkland, WA', destination: 'University of Washington', travelMode: 'DRIVING', extraComputations: ['TOLLS'], routeModifiers: { vehicleInfo: { emissionType: 'GASOLINE', }, tollPasses: ['US_WA_GOOD_TO_GO'], }, fields: ['path', 'legs', 'distanceMeters', 'durationMillis', 'travelAdvisory'], };