شما مشخص میکنید که از کدام ویژگیهای مسیر اجتناب کنید، مانند اجتناب از عوارض یا بزرگراهها، با افزودن اصلاحکنندههای مسیر به درخواست. سپس API سعی می کند مسیری را ارائه دهد که به آن ویژگی ها نیاز ندارد.
از ویژگی routeModifiers در یک درخواست از نوع RouteModifiers استفاده کنید. شما می توانید avoidTolls ، avoidHighways ، avoidFerries ، و avoidIndoor را مشخص کنید.
تعیین یک تغییر دهنده مسیر لزوماً مسیرهایی را که شامل ویژگی محدود شده هستند حذف نمی کند. API از اصلاح کننده برای سوگیری نتیجه به مسیرهای مطلوب تر استفاده می کند. ممکن است چند دلیل وجود داشته باشد که درخواست گزینه اجتناب مسیر شما را تغییر نمی دهد. به عنوان مثال، تنها مسیر از مبدا تا مقصد، اجتناب از بزرگراه یا کشتی را غیرممکن می کند. یا، مسیر جایگزین در واقع زمان سفر را به میزان قابل توجهی افزایش می دهد.
مثال زیر نحوه تنظیم اصلاح کننده های مسیر را در بدنه درخواست متد computeRoutes (REST) نشان می دهد. همچنین می توانید این گزینه را به روش ComputeRoutes (gRPC) مشخص کنید. در این مثال، شما برای جلوگیری از عوارض و بزرگراه ها مشخص می کنید:
تاریخ آخرین بهروزرسانی 2025-02-05 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-02-05 بهوقت ساعت هماهنگ جهانی."],[[["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"]]