Deweloperzy z Europejskiego Obszaru Gospodarczego (EOG)
Możesz określić, których elementów trasy chcesz uniknąć, np. dróg płatnych lub autostrad, dodając do żądania modyfikatory trasy. Następnie interfejs API próbuje podać trasę, która nie wymaga tych funkcji.
Użyj w żądaniu właściwości routeModifiers typu RouteModifiers. Możesz podać avoidTolls, avoidHighways, avoidFerries i avoidIndoor.
Podanie modyfikatora trasy niekoniecznie eliminuje trasy, które obejmują funkcję objętą ograniczeniem. Interfejs API używa modyfikatora, aby preferować bardziej korzystne trasy. Istnieje kilka powodów, dla których prośba o opcję omijania nie powoduje zmiany trasy. Na przykład jedyna trasa z miejsca wyjazdu do miejsca docelowego nie pozwala uniknąć autostrady lub promu. Albo alternatywna trasa znacznie wydłuża czas podróży.
W tym przykładzie pokazujemy, jak ustawiać modyfikatory trasy w ciele metody computeRoutes (REST). Możesz też podać tę opcję metodzie ComputeRoutes (gRPC). W tym przykładzie określasz, że chcesz unikać dróg płatnych i autostrad:
[null,null,["Ostatnia aktualizacja: 2025-06-20 UTC."],[[["The Routes API's Compute Route Matrix feature does not support avoiding route features."],["You can request routes that avoid tolls, highways, ferries, and indoor travel using the `routeModifiers` property."],["While route modifiers bias the results, they may not eliminate the specified features if alternatives are unavailable or significantly increase travel time."],["You can specify route modifiers in both REST and gRPC requests, using the `avoidTolls`, `avoidHighways`, `avoidFerries`, and `avoidIndoor` fields within the `routeModifiers` property."]]],["Route modifiers, set in the `routeModifiers` property of a request, allow users to express preferences for avoiding tolls, highways, ferries, or indoor routes. The `Compute Route Matrix` feature does not support avoiding route features. Modifiers bias the route calculation, but do not guarantee avoidance. `routeModifiers` also supports `vehicleInfo` and `tollPasses`. The API might include the feature to be avoided if no practical alternative exists. An example in a `computeRoutes` request demonstrates setting `avoidTolls` and `avoidHighways` to `true`.\n"]]