Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Entwickler im Europäischen Wirtschaftsraum (EWR)
Wenn Sie eine Routenmatrix berechnen, sollten Sie alle Mautgebühren für die Routen in der Matrix berücksichtigen. In ausgewählten Städten können Sie die geschätzte Mautgebühr für eine Route in der entsprechenden Währung berechnen.
Eine Liste der unterstützten Mautstellen finden Sie in der Referenz für TollPass.
Beispiel für Mautgebühren in einer Routenmatrix
Im folgenden Beispiel wird die Methode computeRouteMatrix verwendet, um Mautinformationen für eine Route mit einem geschätzten Preis zurückzugeben, wenn eine Mautkarte verwendet wird:
Setzen Sie das Arrayfeld extraComputations auf TOLLS, um die Berechnung von Mautinformationen zu aktivieren.
Geben Sie den Fahrzeugtyp und den Mautpass-Typ mit dem Feld routeModifiers der origin-Wegpunkte der Anfrage an. Der zurückgegebene Mautpreis basiert auf den Preisen, die für den angegebenen Fahrzeugtyp und Pass gelten. Wenn mehrere Karten angegeben sind, wird der günstigste Preis zurückgegeben.
Verwenden Sie die Antwortfeldmaske, um die Methode so zu konfigurieren, dass Mautinformationen in der Antwort zurückgegeben werden. Geben Sie routes.travelAdvisory.tollInfo an, um Informationen für die gesamte Route zurückzugeben.
Anfrage nach Mautinformationen für eine Routenmatrix
Antwort für Mautinformationen für die Routenmatrix
Die Antwort enthält Informationen zu Mautgebühren in einem TollInfo- (REST) oder TollInfo-Objekt (gRPC).
Wenn Sie die Methode so konfigurieren möchten, dass Mautinformationen zurückgegeben werden, verwenden Sie die Antwortfeldmaske, um das Feld travelAdvisory.tollInfo in der Maske festzulegen.
[null,null,["Zuletzt aktualisiert: 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```"]]