フィードバックを送信
ルート マトリックス レスポンスを確認する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
ルート行列リクエストは、出発地と目的地のウェイポイントの配列を入力として受け取ります。Routes API は、各出発地のウェイポイントから各目的地のウェイポイントまでのルートを計算します。たとえば、2 つの出発地点と 2 つの目的地点を指定すると、API は 4 つの個別のルートを計算します。
API レスポンスには配列が含まれます。配列の各要素は、1 つの出発地のウェイポイントから 1 つの目的地のウェイポイントへのルートに相当します。したがって、2 つの出発地と 2 つの目的地の地点を指定すると、レスポンス配列には、計算されたルートごとに 1 つずつ、4 つの要素が含まれます。
レスポンスを使用して、さまざまなルート オプションをユーザーに提示し、ユーザーが要件に適したルートを選択できるようにします。
注: ルート マトリックスは、ルートの経路、ステップ、ポリラインなどの詳細なルート情報を返しません。詳細なルート情報を取得するには、出発地と目的地を 1 つずつ Compute Routes に渡します。 フィールド マスクについて
メソッドを呼び出してルートを計算する場合は、レスポンスで返されるフィールドを定義するフィールドマスクを指定する必要があります。返されるフィールドのデフォルト リストはありません。このリストを省略すると、メソッドはエラーを返します。
このドキュメントの例では、フィールドマスクを考慮せずにレスポンス オブジェクト全体を示しています。本番環境では、項目マスクで明示的に指定したフィールドのみがレスポンスに含まれます。
詳細については、返される情報を選択する をご覧ください。
著作権の表示について
結果をユーザーに表示する際には、次の著作権に関する声明を含める必要があります。
Powered by Google, ©YEAR Google
次に例を示します。
Powered by Google, ©2023 Google
レスポンスでルートを特定する
レスポンスの originIndex
プロパティと destinationIndex
プロパティを使用して、レスポンスの各ルートを特定します。これらのプロパティには、ルートの計算に使用される入力出発地 と入力目的地 のウェイポイントのゼロベース のインデックスが含まれています。つまり、リクエスト内の最初の出発地のウェイポイントと最初の目的地のウェイポイントは、配列インデックス 0 にあります。
たとえば、レスポンスのルートには次の情報が含まれます。
"originIndex" : 1 ,
"destinationIndex" : 0
これらのプロパティは、ルートが入力配列のインデックス 1 の出発地のウェイポイントと、インデックス 0 の目的地のウェイポイントから計算されたことを示します。
次のルートの場合:
"originIndex" : 4 ,
"destinationIndex" : 1
ルートは、入力配列のインデックス 4 の出発地ウェイポイントと、入力配列のインデックス 1 の目的地ウェイポイントから計算されました。
レスポンスについて
API レスポンスを表す JSON オブジェクト には配列が含まれます。各配列要素は、1 つの出発地のウェイポイントから 1 つの目的地のウェイポイントへのルートを定義します。
各ルートは、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)
}
}
…
]
フィードバックを送信
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンス により使用許諾されます。コードサンプルは Apache 2.0 ライセンス により使用許諾されます。詳しくは、Google Developers サイトのポリシー をご覧ください。Java は 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```"]]