Calcular tarifas de pedágio para uma matriz de trajetos
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Desenvolvedores do Espaço Econômico Europeu (EEE)
Ao calcular uma matriz de rotas, talvez você queira considerar as taxas de pedágio nas rotas da matriz. Em algumas cidades, é possível calcular o valor estimado do pedágio de um trajeto na moeda adequada.
Para conferir a lista de locais com pedágio aceitos, consulte a referência de
TollPass.
Exemplo de pedágio da matriz de rotas
O exemplo a seguir usa o método
computeRouteMatrix
para retornar informações de pedágio em uma rota com um preço
estimado quando um passe de pedágio é usado:
Defina o campo de matriz extraComputations como TOLLS para ativar o cálculo
das informações de pedágio.
Especifique o tipo de veículo e de pedágio usando o campo
routeModifiers dos pontos de referência de origem da solicitação. O preço do pedágio retornado é baseado nos preços usados pelo tipo de veículo e passe especificados. Se mais de uma passagem for especificada, o preço mais baixo será retornado.
Use a máscara de campo de resposta para configurar o método e
retornar informações de pedágio na resposta. Especifique
routes.travelAdvisory.tollInfo para retornar informações sobre todo o trajeto.
Solicitação de informações de pedágio de uma matriz de rotas
Resposta para informações de pedágio da matriz de rotas
A resposta contém informações sobre pedágios em um objeto TollInfo (REST) ou TollInfo (gRPC).
Para configurar o método para retornar informações de pedágio, use a
máscara de campo de resposta para definir o campo travelAdvisory.tollInfo
na máscara.
[null,null,["Última atualização 2025-09-04 UTC."],[[["\u003cp\u003eThe Routes API's \u003ccode\u003ecomputeRouteMatrix\u003c/code\u003e method allows you to calculate estimated toll fees for routes in supported cities, providing cost insights for route planning.\u003c/p\u003e\n"],["\u003cp\u003eTo enable toll calculations, specify \u003ccode\u003eTOLLS\u003c/code\u003e in the \u003ccode\u003eextraComputations\u003c/code\u003e field and provide vehicle and toll pass details in the \u003ccode\u003erouteModifiers\u003c/code\u003e field within the request.\u003c/p\u003e\n"],["\u003cp\u003eToll prices are estimates and are influenced by factors like vehicle type and toll pass used, with the response including the estimated price in the specified currency.\u003c/p\u003e\n"],["\u003cp\u003eWhile the Route Matrix provides toll information, detailed route specifics are not included; for that, use the \u003ccode\u003eCompute Routes\u003c/code\u003e functionality with single origin and destination points.\u003c/p\u003e\n"],["\u003cp\u003eBe aware that requests including toll fee calculations are billed at a higher rate than standard route matrix requests.\u003c/p\u003e\n"]]],["To calculate toll fees for a route matrix, set the `extraComputations` field to `TOLLS`. Specify the vehicle type and toll pass using the `routeModifiers` field within the origin waypoints; the lowest-cost toll pass pricing will be applied if multiple passes are set. Use the response field mask with `routes.travelAdvisory.tollInfo` to include toll information, and note that toll fee requests have a higher billing rate. The response then contains `estimatedPrice`.\n"],null,["# Calculate toll fees for a route matrix\n\n**European Economic Area (EEA) developers** If your billing address is in the European Economic Area, effective on 8 July 2025, the [Google Maps Platform EEA Terms of Service](https://cloud.google.com/terms/maps-platform/eea) will apply to your use of the Services. Functionality varies by region. [Learn more](/maps/comms/eea/faq).\n\nWhen you are computing a route matrix, you might want to take into consideration\nany toll fees on the routes in the matrix. For select cities, you can compute\nthe estimated toll fee for a route in the appropriate currency.\n\nTo get tolls for a route, see\n[Calculate tolls fees for a route](/maps/documentation/routes/calculate_toll_fees).\n\nFor the list of supported toll locations, see the reference for\n[TollPass](/maps/documentation/routes/reference/rest/v2/RouteModifiers#tollpass).\n| **Caution:** Requests that calculate toll fees are billed at a higher rate. [Learn more about billing](/maps/documentation/routes/usage-and-billing) for the Routes API.\n\nRoute matrix toll example\n-------------------------\n\nThe following example uses the\n[`computeRouteMatrix`](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRouteMatrix)\nmethod to return toll information on a route with an estimated\nprice when a toll pass is used:\n\n- Set the `extraComputations` array field to `TOLLS` to enable the calculation\n of toll information.\n\n- Specify the vehicle type and the toll pass type by using the\n `routeModifiers` field of the *origin* waypoints of the request. The toll\n price returned is based on the pricing used by the specified vehicle type\n and pass. If more than one pass is specified, the least expensive pricing is\n returned.\n\n- Use the [response field mask](/maps/documentation/routes/choose_fields) to configure the method to\n return toll information in the response. Specify\n `routes.travelAdvisory.tollInfo` to return information for the entire route.\n\n| **Note:** Route matrix does not return detailed route information, such as the legs, steps, and polylines of the route. To obtain detailed route information, pass a single origin and single destination to [Compute\n| Routes](/maps/documentation/routes/compute_route_directions).\n\n### Request for a route matrix toll information\n\n```console\ncurl -X POST -d '{\n\"origins\": [\n {\n \"waypoint\": {\n \"location\": {\n \"latLng\": {\n \"latitude\":42.340173523716736,\n \"longitude\":-71.05997968330408\n }\n }\n },\n \"routeModifiers\": {\n \"vehicleInfo\":{\n \"emissionType\": \"GASOLINE\"\n },\n \"tollPasses\": [\n \"US_MA_EZPASSMA\",\n \"US_WA_GOOD_TO_GO\"\n ]\n }\n }\n],\n\"destinations\": [\n {\n \"waypoint\": {\n \"location\": {\n \"latLng\": {\n \"latitude\":42.075698891472804,\n \"longitude\": -72.59806562080408\n }\n }\n }\n }\n],\n\"travelMode\": \"DRIVE\",\n\"extraComputations\": [\"TOLLS\"]\n}' \\\n-H 'Content-Type: application/json' \\\n-H 'X-Goog-Api-Key: \u003cvar translate=\"no\"\u003eYOUR_API_KEY\u003c/var\u003e' \\\n-H 'X-Goog-FieldMask: originIndex,destinationIndex,travel_advisory.tollInfo,duration,distanceMeters,status' \\\n'https://routes.googleapis.com/distanceMatrix/v2:computeRouteMatrix'\n```\n\n### Response for route matrix toll information\n\nThe response contains information on tolls in a\n[TollInfo](/maps/documentation/routes/reference/rest/v2/TollInfo) (REST) or\n[TollInfo](/maps/documentation/routes/reference/rpc/google.maps.routing.v2#tollinfo) (gRPC) object.\n\nTo configure the method to return toll information, use the\n[response field mask](/maps/documentation/routes/choose_fields) to set the `travelAdvisory.tollInfo` field\nin the mask. \n\n```json\n[\n {\n \"originIndex\": 0,\n \"destinationIndex\": 0,\n \"status\": {},\n \"distanceMeters\": 150338,\n \"duration\": \"5382s\",\n \"travelAdvisory\": {\n \"tollInfo\": {\n \"estimatedPrice\": [\n {\n \"currencyCode\": \"USD\",\n \"units\": \"4\",\n \"nanos\": 400000000\n }\n ]\n }\n }\n }\n]\n```"]]