Calcola le tariffe per i pedaggi per una matrice di percorso
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Sviluppatori dello Spazio economico europeo (SEE)
Quando calcoli una matrice di itinerari, potresti voler prendere in considerazione
eventuali pedaggi sugli itinerari della matrice. Per alcune città, puoi calcolare
il pedaggio stimato per un percorso nella valuta appropriata.
Per l'elenco delle località con pedaggio supportate, consulta il riferimento per
TollPass.
Esempio di pedaggio della matrice di itinerari
L'esempio seguente utilizza il metodo
computeRouteMatrix
per restituire le informazioni sui pedaggi di un itinerario con un prezzo stimato
quando viene utilizzato un abbonamento per il pedaggio:
Imposta il campo dell'array extraComputations su TOLLS per attivare il calcolo
delle informazioni sui pedaggi.
Specifica il tipo di veicolo e il tipo di pedaggio utilizzando il campo routeModifiers dei waypoint origine della richiesta. Il prezzo
del pedaggio restituito si basa sui prezzi utilizzati dal tipo di veicolo
e dal pass specificati. Se viene specificato più di un abbonamento, viene restituito il prezzo meno costoso.
Utilizza la maschera del campo di risposta per configurare il metodo per restituire le informazioni sul pedaggio nella risposta. Specifica
routes.travelAdvisory.tollInfo per restituire informazioni sull'intero percorso.
Richiesta di informazioni sui pedaggi per una matrice di itinerari
Risposta per le informazioni sui pedaggi della matrice di itinerari
La risposta contiene informazioni sui pedaggi in un oggetto TollInfo (REST) o TollInfo (gRPC).
Per configurare il metodo per restituire le informazioni sui pedaggi, utilizza la
maschera del campo di risposta per impostare il campo travelAdvisory.tollInfo
nella maschera.
[null,null,["Ultimo aggiornamento 2025-08-10 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```"]]