交通模型使用特定算法和因素来预测交通状况对给定路线的总行程时间有何影响。Routes API 提供不同的交通模型类型,以便确定计算交通时长时要优先考虑的不同因素。您可以在计算路线或路线矩阵的用时时,指定路线应使用的交通模型类型。设置流量模型类型后,duration 字段中返回的值会因您选择的流量模型而异。
Routes API Compute Routes 和 Compute Route Matrix 方法都支持交通模型类型。
[null,null,["最后更新时间 (UTC):2025-02-06。"],[[["The Routes API offers different traffic models (`BEST_GUESS`, `PESSIMISTIC`, `OPTIMISTIC`) to predict travel times based on various traffic conditions."],["You can specify the desired traffic model when calculating routes, with `BEST_GUESS` being the default, providing the most useful predictions for most use cases."],["`PESSIMISTIC` models travel time based on bad traffic days, likely resulting in a longer estimated duration, while `OPTIMISTIC` uses good traffic days, potentially resulting in a shorter duration."],["Live traffic information is integrated into the `BEST_GUESS` model, making it potentially shorter than `OPTIMISTIC` or longer than `PESSIMISTIC`."],["To use traffic models, include the `trafficModel` parameter in your request and specify `routes.duration` in the field mask."]]],["The Routes API's traffic models predict travel time, offering `BEST_GUESS` (default), `PESSIMISTIC` (longer), and `OPTIMISTIC` (shorter) durations. To use, set the origin, destination, and optional `departure_time`. Choose a `trafficModel` type and specify `routes.duration` in the field mask. The API calculates traffic-affected durations based on the selected model. Using `BEST_GUESS` integrate live information. The default is `BEST_GUESS`, and the duration returned varies depending on the chosen model. The service is pre-GA, it might have limited support and changes.\n"]]