Routes Preferred API 目前仅适用于部分客户。如需了解详情,请
与销售人员联系。
ComputeRouteMatrixRequest
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
字段 |
origins[] |
object (RouteMatrixOrigin )
必需。来源数组,用于确定响应矩阵的行。起点和目的地的基数受到以下大小限制:
- 在任何情况下,元素(出发地 × 目的地)的数量都不得超过 625 个。
- 如果 routingPreference 设置为
TRAFFIC_AWARE_OPTIMAL ,元素数量(起点 × 终点)不得超过 100。
- 指定为
placeId 的路点(起点 + 终点)的数量不得超过 50 个。
|
destinations[] |
object (RouteMatrixDestination )
必需。目的地数组,用于确定响应矩阵的列。
|
travelMode |
enum (RouteTravelMode )
可选。指定交通方式。
|
routingPreference |
enum (RoutingPreference )
可选。指定如何计算路线。服务器会尝试使用所选的路由偏好设置来计算路由。如果路由偏好设置导致错误或延迟时间过长,则返回错误。只有当 travelMode 为 DRIVE 或 TWO_WHEELER 时,您才能指定此选项,否则请求会失败。
|
departureTime |
string (Timestamp format)
可选。出发时间。如果您未设置此值,则默认为您发出请求的时间。如果您将此值设置为已过的时间,请求将失败。 时间戳采用 RFC3339 世界协调时间(UTC,即“祖鲁时”)格式,精确到纳秒,最多九个小数位。示例:"2014-10-02T15:01:23Z" 和 "2014-10-02T15:01:23.045123456Z" 。
|
RouteMatrixOrigin
ComputeRouteMatrixRequest 的单个来源
RouteMatrixDestination
ComputeRouteMatrixRequest 的单个目的地
JSON 表示法 |
{
"waypoint": {
object (Waypoint )
}
} |
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-31。
[null,null,["最后更新时间 (UTC):2025-08-31。"],[[["\u003cp\u003eThe ComputeRouteMatrix request calculates travel times and distances between multiple origins and destinations.\u003c/p\u003e\n"],["\u003cp\u003eRequests must include origins and destinations, with optional parameters for travel mode, routing preference, and departure time.\u003c/p\u003e\n"],["\u003cp\u003eThe maximum number of origins and destinations is limited based on routing preferences and waypoint types.\u003c/p\u003e\n"],["\u003cp\u003eOrigins and destinations are defined using waypoints, and origins can optionally include route modifiers.\u003c/p\u003e\n"]]],["The core content describes the `ComputeRouteMatrix` request, which calculates routes between multiple origins and destinations. Key actions involve specifying arrays of `origins` and `destinations`, each containing a `waypoint`. Optional parameters include `travelMode`, `routingPreference`, and `departureTime`. Size limitations apply to the number of origins and destinations: their product must not exceed 625 and no more than 50 if they are placeIds. Each `RouteMatrixOrigin` and `RouteMatrixDestination` have a `waypoint`, and `RouteMatrixOrigin` additionally allows for `routeModifiers`.\n"],null,["# ComputeRouteMatrixRequest\n\n- [JSON representation](#SCHEMA_REPRESENTATION)\n- [RouteMatrixOrigin](#RouteMatrixOrigin)\n - [JSON representation](#RouteMatrixOrigin.SCHEMA_REPRESENTATION)\n- [RouteMatrixDestination](#RouteMatrixDestination)\n - [JSON representation](#RouteMatrixDestination.SCHEMA_REPRESENTATION)\n\nComputeRouteMatrix request message\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"origins\": [ { object (/maps/documentation/routes_preferred/reference/rest/Shared.Types/ComputeRouteMatrixRequest#RouteMatrixOrigin) } ], \"destinations\": [ { object (/maps/documentation/routes_preferred/reference/rest/Shared.Types/ComputeRouteMatrixRequest#RouteMatrixDestination) } ], \"travelMode\": enum (/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode), \"routingPreference\": enum (/maps/documentation/routes_preferred/reference/rest/Shared.Types/RoutingPreference), \"departureTime\": string } ``` |\n\n| Fields ||\n|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `origins[]` | `object (`[RouteMatrixOrigin](/maps/documentation/routes_preferred/reference/rest/Shared.Types/ComputeRouteMatrixRequest#RouteMatrixOrigin)`)` Required. Array of origins, which determines the rows of the response matrix. Several size restrictions apply to the cardinality of origins and destinations: - The number of elements (origins × destinations) must be no greater than 625 in any case. - The number of elements (origins × destinations) must be no greater than 100 if routingPreference is set to `TRAFFIC_AWARE_OPTIMAL`. - The number of waypoints (origins + destinations) specified as `placeId` must be no greater than 50. |\n| `destinations[]` | `object (`[RouteMatrixDestination](/maps/documentation/routes_preferred/reference/rest/Shared.Types/ComputeRouteMatrixRequest#RouteMatrixDestination)`)` Required. Array of destinations, which determines the columns of the response matrix. |\n| `travel``Mode` | `enum (`[RouteTravelMode](/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteTravelMode)`)` Optional. Specifies the mode of transportation. |\n| `routing``Preference` | `enum (`[RoutingPreference](/maps/documentation/routes_preferred/reference/rest/Shared.Types/RoutingPreference)`)` Optional. Specifies how to compute the route. The server attempts to use the selected routing preference to compute the route. If the routing preference results in an error or an extra long latency, an error is returned. You can specify this option only when the `travelMode` is `DRIVE` or `TWO_WHEELER`, otherwise the request fails. |\n| `departure``Time` | `string (`[Timestamp](https://protobuf.dev/reference/protobuf/google.protobuf/#timestamp)` format)` Optional. The departure time. If you don't set this value, this defaults to the time that you made the request. If you set this value to a time that has already occurred, the request fails. A timestamp in RFC3339 UTC \"Zulu\" format, with nanosecond resolution and up to nine fractional digits. Examples: `\"2014-10-02T15:01:23Z\"` and `\"2014-10-02T15:01:23.045123456Z\"`. |\n\nRouteMatrixOrigin\n-----------------\n\nA single origin for ComputeRouteMatrixRequest\n\n| JSON representation |\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ``` { \"waypoint\": { object (/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint) }, \"routeModifiers\": { object (/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteModifiers) } } ``` |\n\n| Fields ||\n|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `waypoint` | `object (`[Waypoint](/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint)`)` Required. Origin waypoint |\n| `route``Modifiers` | `object (`[RouteModifiers](/maps/documentation/routes_preferred/reference/rest/Shared.Types/RouteModifiers)`)` Optional. Modifiers for every route that takes this as the origin |\n\nRouteMatrixDestination\n----------------------\n\nA single destination for ComputeRouteMatrixRequest\n\n| JSON representation |\n|----------------------------------------------------------------------------------------------------------------|\n| ``` { \"waypoint\": { object (/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint) } } ``` |\n\n| Fields ||\n|------------|-----------------------------------------------------------------------------------------------------------------------------------|\n| `waypoint` | `object (`[Waypoint](/maps/documentation/routes_preferred/reference/rest/Shared.Types/Waypoint)`)` Required. Destination waypoint |"]]