요청 메시지 구성
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
경로 최적화 개요에 간략하게 설명된 대로 기본 요청은 필수 항목인 모델, 배송, 차량으로 구성됩니다.
- 모델은
Shipments
와 Vehicles
를 모두 포함한 전체 요청의 설정과 제약 조건을 캡처합니다.
- 배송은 픽업 및 배송
VisitRequest
를 포함하는 작업 또는 실제 배송을 나타냅니다. 배송에는 로컬 설정과 제약 조건이 있습니다.
- 차량은 차량, 운전자 또는 인력을 나타냅니다. 차량에는 로컬 설정과 제약 조건도 있습니다.
각 항목의 속성은 특정 세부사항 수준에서 최적화 문제의 일부를 설명합니다. 모델 전체 제약 조건은 모든 배송 및 차량에 적용되는 반면 배송 또는 차량에 지정된 제약 조건과 속성은 단일 배송 또는 차량에만 적용됩니다.
각 메시지 유형에 관한 전체 문서는 ShipmentModel
(REST, gRPC), Shipment
(REST, gRPC), Vehicle
(REST, gRPC) 메시지의 참조 문서를 참고하세요.
숙박 시설 OptimizeToursRequest
개
최상위 OptimizeToursRequest
메시지(REST, gRPC)의 일반적으로 사용되는 속성은 다음과 같습니다.
searchMode
는 지정된 제약 조건을 충족하는 첫 번째 솔루션을 반환할지 아니면 정해진 기한 내에 최적의 솔루션을 찾을지를 나타냅니다.
considerRoadTraffic
는 라우팅 및 ETA 추정에 실시간 교통정보를 사용할지 여부를 결정합니다.
populateTransitionPolylines
는 경로 폴리라인과 경로 토큰이 응답에 반환되는지 여부를 결정합니다.
모델 속성
ShipmentModel
메시지 (REST, gRPC)의 일반적으로 사용되는 속성은 다음과 같습니다.
globalStartTime
는 모든 차량과 배송의 경로 중 가장 빠른 시작 시간을 나타냅니다. 이 시간 전에 차량이 첫 번째 전환 및 배송을 시작할 수 없습니다.
globalEndTime
는 모든 차량과 배송의 경로 중 가장 늦은 종료 시간을 나타냅니다. 이 시간 전에 할당된 모든 배송과 전환이 완료되어야 합니다.
배송 속성
Shipment
메시지 (REST, gRPC)의 일반적으로 사용되는 속성은 다음과 같습니다.
pickups[]
및 deliveries[]
은 배송 상품을 수령하거나 반품할 수 있는 위치를 나타냅니다. pickups[]
및 deliveries[]
속성은 모두 VisitRequest
메시지 (REST, gRPC)를 사용합니다.
loadDemands
는 차량이 배송을 완료하는 데 필요한 적재량을 나타냅니다. 차량의 해당 load_limits
(REST, gRPC) 속성은 차량이 한 번에 수용할 수 있는 부하를 나타냅니다.
부하 요구사항 및 한도에서 부하에 대해 자세히 알아보세요.
penalty_cost
는 배송을 건너뛸 경우 발생하는 비용을 나타냅니다. 비용 모델 매개변수에서 비용에 대해 자세히 알아보세요.
차량 속성
Vehicle
메시지 (REST, gRPC)의 일반적으로 사용되는 속성은 다음과 같습니다.
startLocation
는 차량이 경로를 시작해야 하는 위치를 나타냅니다. 이 속성은 선택사항입니다. 지정하지 않으면 차량의 경로가 처음 할당된 배송의 위치에서 시작됩니다.
endLocation
는 차량이 경로를 종료해야 하는 위치를 나타냅니다. 이 속성은 선택사항입니다. 지정하지 않으면 차량의 경로가 마지막으로 할당된 배송의 위치에서 종료됩니다.
startTimeWindows[]
는 차량이 경로를 시작할 수 있는 시간을 나타냅니다. 이 속성은 선택사항입니다.
endTimeWindows[]
는 차량이 경로를 시작하고 종료할 수 있는 시간을 나타냅니다.
두 속성 모두 선택사항입니다.
loadLimits
는 배송의 적재 요구사항을 충족하는 데 사용할 수 있는 차량의 용량을 나타냅니다. 부하 요구사항 및 제한사항에서 부하 요구사항 및 제한사항에 대해 자세히 알아보세요.
JSON 형식의 전체 요청 예시는 다음과 같습니다.
{
"model": {
"shipments": [
{
"pickups": [
{
"arrivalLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
}
}
],
"deliveries": [
{
"arrivalLocation": {
"latitude": 37.79581,
"longitude": -122.4218856
}
}
]
}
],
"vehicles": [
{
"startLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"endLocation": {
"latitude": 37.73881799999999,
"longitude": -122.4161
},
"costPerKilometer": 1.0
}
],
"globalStartTime": "2024-02-13T00:00:00.000Z",
"globalEndTime": "2024-02-14T06:00:00.000Z"
}
}
OptimizeTours
와 BatchOptimizeTours
는 모두 위의 예와 같은 요청 메시지를 사용하지만 방식은 다릅니다. 경로 최적화 요청을 하기 전에 다음 두 가지 방법의 차이점을 이해하는 것이 중요합니다.
OptimizeTours와 BatchOptimizeTours 비교
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eRoute Optimization requests require defining a \u003ccode\u003eModel\u003c/code\u003e with \u003ccode\u003eShipments\u003c/code\u003e and \u003ccode\u003eVehicles\u003c/code\u003e to represent the optimization problem.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eModel\u003c/code\u003e sets global parameters, while \u003ccode\u003eShipments\u003c/code\u003e and \u003ccode\u003eVehicles\u003c/code\u003e have individual properties and constraints for pickups, deliveries, loads, and time windows.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeToursRequest\u003c/code\u003e allows controlling the search mode, traffic considerations, and response details.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eOptimizeTours\u003c/code\u003e and \u003ccode\u003eBatchOptimizeTours\u003c/code\u003e offer synchronous and asynchronous request processing, respectively, with key differences in handling large or complex scenarios.\u003c/p\u003e\n"],["\u003cp\u003eYou can specify global start and end times for all vehicles and shipments within the \u003ccode\u003eShipmentModel\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Construct a request message\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\nAs briefly described in [Route Optimization Overview](/maps/documentation/route-optimization/overview), a basic request\nconsists of **Model** , **Shipments** , and **Vehicles** as required entities:\n\n- **Model** captures settings and constraints for the entire request, inclusive of both `Shipments` and `Vehicles`.\n- **Shipments** represent tasks or actual shipments that include pickup and delivery `VisitRequest`s. Shipments have local settings and constraints.\n- **Vehicles** represent vehicles, drivers, or personnel. Vehicles also have local settings and constraints.\n\nEach entity's properties describe part of an optimization problem at a\nparticular level of granularity. Model-wide constraints are applied to all\nshipments and vehicles, while constraints and properties specified on shipments\nor vehicles are specific to a single shipment or vehicle.\n\nFor complete documentation on each message type, see the reference documentation\nfor `ShipmentModel` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.ShipmentModel)), `Shipment` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Shipment), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment)),\nand `Vehicle` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle)) messages.\n\n`OptimizeToursRequest` properties\n---------------------------------\n\nSome commonly used properties of the top-level `OptimizeToursRequest` message\n([REST](/maps/documentation/route-optimization/reference/rest/v1/projects/optimizeTours), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.OptimizeToursRequest)) include the following:\n\n- `searchMode` indicates whether to return the first solution that satisfies specified constraints or find the best possible solution within a set deadline.\n- `considerRoadTraffic` determines whether or not live traffic is used for routing and ETA estimation.\n- `populateTransitionPolylines` determines whether or not route polylines and route tokens are returned in the response.\n\nModel properties\n----------------\n\nSome commonly used properties of the `ShipmentModel` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel),\n[gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.ShipmentModel)) include:\n\n- `globalStartTime` represents the earliest start time of routes across all vehicles and shipments. No vehicle may start its first transitions and shipments before this time.\n- `globalEndTime` represents the latest end time of routes across all vehicles and shipments. All assigned shipments and transitions must be complete before this time.\n\nShipment properties\n-------------------\n\nSome commonly used properties of the `Shipment` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Shipment), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment))\ninclude:\n\n- `pickups[]` and `deliveries[]` represent where a shipment can be picked up or dropped off. `pickups[]` and `deliveries[]` properties both use the `VisitRequest` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#VisitRequest), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Shipment.VisitRequest)).\n- `loadDemands` represent the load required for a vehicle to complete a shipment. Vehicles' corresponding `load_limits` ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle.FIELDS.load_limits), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle.FIELDS.repeated.google.maps.routeoptimization.v1.Vehicle.LoadLimitsEntry.google.maps.routeoptimization.v1.Vehicle.load_limits)) property represents how much load a vehicle can accommodate at one time. Read more about load in [Load Demands and Limits](/maps/documentation/route-optimization/load-demands-limits).\n- `penalty_cost` represents the cost incurred if a shipment is skipped. Read more on costs in [Cost Model Parameters](/maps/documentation/route-optimization/cost-model).\n\nVehicle properties\n------------------\n\nSome commonly used properties of the `Vehicle` message ([REST](/maps/documentation/route-optimization/reference/rest/v1/ShipmentModel#Vehicle), [gRPC](/maps/documentation/route-optimization/reference/rpc/google.maps.routeoptimization.v1#google.maps.routeoptimization.v1.Vehicle))\ninclude:\n\n- `startLocation` represents where a vehicle must start its route. This property is optional. If not specified, the vehicle's route starts at the location of its first assigned shipment.\n- `endLocation` represents where a vehicle must end its route. This property is optional. If not specified, the vehicle's route ends at the location of its last assigned shipment.\n- `startTimeWindows[]` represents when a vehicle can start its route. This property is optional.\n- `endTimeWindows[]` represents when a vehicle can start and end its route. Both properties are optional.\n- `loadLimits` represent the vehicle's capacity available to meet shipments' load demands. Read more about load demands and limits in [Load Demands and\n Limits](/maps/documentation/route-optimization/load-demands-limits).\n\nA complete example request in JSON format looks like: \n\n {\n \"model\": {\n \"shipments\": [\n {\n \"pickups\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n }\n }\n ],\n \"deliveries\": [\n {\n \"arrivalLocation\": {\n \"latitude\": 37.79581,\n \"longitude\": -122.4218856\n }\n }\n ]\n }\n ],\n \"vehicles\": [\n {\n \"startLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n },\n \"endLocation\": {\n \"latitude\": 37.73881799999999,\n \"longitude\": -122.4161\n },\n \"costPerKilometer\": 1.0\n }\n ],\n \"globalStartTime\": \"2024-02-13T00:00:00.000Z\",\n \"globalEndTime\": \"2024-02-14T06:00:00.000Z\"\n }\n }\n\n`OptimizeTours` and `BatchOptimizeTours` both consume request messages like the\nexample above, but in different ways. Before making a Route Optimization\nrequest, it's important to understand the difference between the two methods:\n\n[Comparing OptimizeTours and BatchOptimizeTours](/maps/documentation/route-optimization/sync-vs-async)"]]