의견 보내기
경로 매트릭스 응답 검토
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
경로 행렬 요청은 출발지 및 도착지 웨이포인트 배열을 입력으로 사용합니다. 그러면 Routes API가 각 출발 웨이포인트에서 각 도착 웨이포인트까지의 경로를 계산합니다. 예를 들어 출발 웨이포인트 2개와 도착 웨이포인트 2개를 지정하면 API는 4개의 별도 경로를 계산합니다.
API 응답에는 배열이 포함되며, 각 배열 요소는 하나의 출발 웨이포인트에서 하나의 도착 웨이포인트로의 경로에 해당합니다. 따라서 출발 경유지 2개와 목적지 경유지 2개를 지정하면 응답 배열에는 계산된 경로마다 하나씩 4개의 요소가 포함됩니다.
응답을 사용하여 고객에게 다양한 경로 옵션을 제공한 후 사용자가 요구사항에 적합한 경로를 선택하도록 할 수 있습니다.
참고: 경로 매트릭스는 경로의 구간, 단계, 다중선과 같은 자세한 경로 정보를 반환하지 않습니다. 자세한 경로 정보를 가져오려면 단일 출발지와 단일 목적지를 경로 계산 에 전달합니다.
필드 마스크에 관한 정보
경로를 계산하는 메서드를 호출할 때는 응답에 반환할 필드를 정의하는 필드 마스크를 지정해야 합니다. 반환되는 필드의 기본 목록은 없습니다. 이 목록을 생략하면 메서드에서 오류를 반환합니다.
이 문서의 예에서는 필드 마스크를 고려하지 않고 전체 응답 객체를 보여줍니다. 프로덕션 환경에서는 필드 마스크에 명시적으로 지정한 필드만 응답에 포함됩니다.
자세한 내용은 반환할 정보 선택 을 참고하세요.
저작권 표시 정보
사용자에게 결과를 표시할 때 다음 저작권 고지를 포함해야 합니다.
Powered by Google, ©YEAR Google
예를 들면 다음과 같습니다.
Powered by Google, ©2023 Google
응답에서 경로 식별
originIndex
및 destinationIndex
응답 속성을 사용하여 응답의 각 경로를 식별합니다. 이 속성에는 경로를 계산하는 데 사용되는 입력 출발 및 입력 도착 웨이포인트의 0부터 시작하는 색인이 포함됩니다. 즉, 요청의 첫 번째 출발 웨이포인트와 첫 번째 도착 웨이포인트는 배열 색인 0에 있습니다.
예를 들어 응답의 경로에는 다음이 포함됩니다.
"originIndex" : 1 ,
"destinationIndex" : 0
이 속성은 경로가 입력 배열의 색인 1에 있는 출발 웨이포인트와 색인 0에 있는 도착 웨이포인트에서 계산되었음을 나타냅니다.
다음 경로의 경우:
"originIndex" : 4 ,
"destinationIndex" : 1
경로는 입력 배열의 색인 4에 있는 출발 웨이포인트와 입력 배열의 색인 1에 있는 도착 웨이포인트에서 계산되었습니다.
응답 정보
API 응답을 나타내는 JSON 객체 에는 배열이 포함되며, 각 배열 요소는 하나의 출발 웨이포인트에서 하나의 도착 웨이포인트로의 경로를 정의합니다.
각 경로에는 originIndex
및 destinationIndex
속성과 함께 distanceMeters
, duration
, travelAdvisory
와 같이 해당 경로에 관한 정보가 포함됩니다.
응답 형식은 다음과 같습니다.
[
// One array element for each combination of origin and destination waypoints.
{
// The route for source waypoint 0 and destination waypoint 0.
"originIndex" : 0 ,
"destinationIndex" : 0 ,
"status" : {
objec t (S tatus )
},
"condition" : e nu m (Rou te Ma tr ixEleme nt Co n di t io n ) ,
"distanceMeters" : i nte ger ,
"duration" : s tr i n g ,
"staticDuration" : s tr i n g ,
"travelAdvisory" : {
objec t (Rou te TravelAdvisory)
},
"fallbackInfo" : {
objec t (FallbackI nf o)
}
}
{
// The route for source waypoint 0 and destination waypoint 1.
"originIndex" : 0 ,
"destinationIndex" : 1 ,
"status" : {
objec t (S tatus )
},
"condition" : e nu m (Rou te Ma tr ixEleme nt Co n di t io n ) ,
"distanceMeters" : i nte ger ,
"duration" : s tr i n g ,
"staticDuration" : s tr i n g ,
"travelAdvisory" : {
objec t (Rou te TravelAdvisory)
},
"fallbackInfo" : {
objec t (FallbackI nf o)
}
}
…
]
의견 보내기
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스 에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스 에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책 을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-06-20(UTC)
의견을 전달하고 싶나요?
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-06-20(UTC)"],[[["\u003cp\u003eThe Routes API's Route Matrix feature calculates routes between multiple origin and destination waypoints, providing travel distance and duration for each route combination.\u003c/p\u003e\n"],["\u003cp\u003eThe API response includes an array of route elements, each containing information like distance, duration, and advisory details for a specific origin-destination pair.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use \u003ccode\u003eoriginIndex\u003c/code\u003e and \u003ccode\u003edestinationIndex\u003c/code\u003e properties to identify the origin and destination waypoints corresponding to each route element in the response.\u003c/p\u003e\n"],["\u003cp\u003eWhile the Route Matrix offers an overview of travel options, it doesn't provide detailed route information; use Compute Routes for turn-by-turn directions.\u003c/p\u003e\n"],["\u003cp\u003eWhen displaying results to users, you must include the copyright statement: \u003ccode\u003ePowered by Google, ©<YEAR> Google\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Review the route matrix response\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\nA route matrix request takes as input an array of origin and destination\nwaypoints. The Routes API then calculates the route from each origin\nwaypoint to each destination waypoint. For example, if you specify two origin\nwaypoints and two destination waypoints, the API then calculates four separate\nroutes.\n\nThe API response contains an array, where each array element corresponds to the\nroute from one origin waypoint to one destination waypoint. Therefore, if you\nspecify two origin waypoints and two destination waypoints, the response array\ncontains four elements, one for each computed route.\n\nUsing the response, you can provide your customers with different route options\nand then let the user select the appropriate route for their requirements.\n| **Note:** Route matrix does not return detailed route information, such as the legs, steps, and polylines of the route. To obtain detailed route information, pass a single origin and single destination to [Compute Routes](/maps/documentation/routes/compute_route_directions).\n\nAbout field masks\n-----------------\n\nWhen you call a method to compute a route, you must specify a field\nmask that defines which fields you want returned in the response. There is no\ndefault list of returned fields. If you omit this list, the methods return an\nerror.\n\nThe examples in this document show the entire response object without taking\nfield masks into consideration. In a production environment, your response would\nonly include the fields that you explicitly specify in the field mask.\n\nFor more information, see [Choose what information to return](/maps/documentation/routes/choose_fields).\n\nAbout displaying copyrights\n---------------------------\n\nYou must include the following copyright statement when displaying the results to your users:\n\n`Powered by Google, ©`\u003cvar translate=\"no\"\u003eYEAR\u003c/var\u003e` Google`\n\nFor example:\n\n`Powered by Google, ©2023 Google`\n\nIdentify the route in the response\n----------------------------------\n\nUse the `originIndex` and `destinationIndex` response properties to identify\neach route in the response. These properties contain the **zero-based** index of\nthe input **origin** and input **destination** waypoints used to calculate the\nroute. That means the first origin waypoint and the first destination waypoint\nin the request are at array index 0.\n\nFor example, a route in the response contains: \n\n```json\n\"originIndex\": 1,\n\"destinationIndex\": 0\n```\n\nThese properties indicate that the route was calculated from the origin\nwaypoint at index 1 in the input array, and from the destination waypoint at\nindex 0.\n\nFor the next route: \n\n```json\n\"originIndex\": 4,\n\"destinationIndex\": 1\n```\n\nThe route was calculated from the origin waypoint at index 4 in the input\narray, and from the destination waypoint at index 1 in the input array.\n\nAbout the response\n------------------\n\nThe\n[JSON object](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRouteMatrix#response-body)\nrepresenting the API response contains an array, where each array element\ndefines the route from one origin waypoint to one destination waypoint.\n\nAlong with the `originIndex` and `destinationIndex` properties, each route\ncontains information specific to that route, such as `distanceMeters`,\n`duration`, and `travelAdvisory`.\n\nThe response has the form: \n\n```json\n[\n // One array element for each combination of origin and destination waypoints.\n {\n // The route for source waypoint 0 and destination waypoint 0.\n \"originIndex\": 0,\n \"destinationIndex\": 0,\n \"status\": {\n object (Status)\n },\n \"condition\": enum (RouteMatrixElementCondition),\n \"distanceMeters\": integer,\n \"duration\": string,\n \"staticDuration\": string,\n \"travelAdvisory\": {\n object (RouteTravelAdvisory)\n },\n \"fallbackInfo\": {\n object (FallbackInfo)\n }\n }\n {\n // The route for source waypoint 0 and destination waypoint 1.\n \"originIndex\": 0,\n \"destinationIndex\": 1,\n \"status\": {\n object (Status)\n },\n \"condition\": enum (RouteMatrixElementCondition),\n \"distanceMeters\": integer,\n \"duration\": string,\n \"staticDuration\": string,\n \"travelAdvisory\": {\n object (RouteTravelAdvisory)\n },\n \"fallbackInfo\": {\n object (FallbackInfo)\n }\n }\n ...\n]\n```"]]