Compute Routes の概要
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。

はじめに
Compute Routes は、HTTPS リクエストを受け取り、2 つの場所間の最適なルートを返す Routes API サービスのメソッドです。複数の地点間の移動について、交通機関や自転車、車、原動機付自転車、徒歩でのルートをリアルタイムの交通情報とともに示します。
ルートマトリックスが必要な場合ルート マトリックスの詳細については、Compute Route Matrix の概要をご覧ください。
移行中ですか?Distance Matrix API(従来版)から移行する場合は、Routes API に移行する理由から移行手順をご覧ください。
Compute Routes を使用する理由
Compute Routes では、さまざまなルート詳細を使用して、費用と品質を最適化しながら、設定に応じて車両やパッケージをルーティングできます。
Compute ルートでできること
Routes API の Compute Routes
メソッドを使用すると、次のことができます。
さまざまな移動手段のルートを検索し、1 つまたは複数のデスティネーションに移動できます。
出発地、目的地、経由地を複数の方法で指定する:
テキスト文字列。たとえば、「シカゴ、イリノイ州」、「ダーウィン、ノーザンテリトリー、オーストラリア」、「1800 Amphitheatre Parkway, Mountain View, CA 94043」、「CWF6+FWX Mountain View, California」などです。
プレイス ID
緯度と経度の座標(車両の向きを含む場合もあります)
ニーズと目標に基づいてルート オプションを微調整します。
フィールド マスクを使用して必要なデータのみをリクエストすることで、レイテンシと品質を制御できます。これにより、不要な処理時間やリクエストの請求レートの増加を回避できます。詳しくは、返される情報を選択するをご覧ください。
Compute Routes の仕組み
Routes API の ComputeRoutes
メソッドは、リクエストの詳細を含む JSON リクエスト本文を含む HTTP POST リクエストを受け入れます。送信元、宛先、travelMode
、返すフィールドを指定するフィールド マスクが必要です。
例
curl -X POST -d '{
"origin": {
"address": "1800 Amphitheatre Parkway, Mountain View, CA 94043"
},
"destination": {
"address": "Sloat Blvd &, Upper Great Hwy, San Francisco, CA 94132"
},
"travelMode": "DRIVE"
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \
-H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters' \
'https://routes.googleapis.com/directions/v2:computeRoutes'
サービスは、リクエストされたルートを計算し、リクエストされたフィールドを返します。
リソース
次の表に、Routes API Compute Routes メソッドで使用可能なリソースと、返されるデータを示します。
データリソース |
返されたデータ |
返品形式 |
ComputeRoutes |
ルート、区間、ステップを返します。リクエストに応じて、代替ルートも返します。 |
JSON |
Compute Routes の使用方法
利用可能なクライアント ライブラリ
Compute ルートで使用可能なクライアント ライブラリのリストについては、クライアント ライブラリをご覧ください。
次のステップ
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-06-20 UTC。
[null,null,["最終更新日 2025-06-20 UTC。"],[],[],null,["# Compute Routes Overview\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\n[](/maps/documentation/routes/demo)\n\nIntroduction\n------------\n\nCompute Routes is a method in the Routes API service that accepts\nan HTTPS request and returns the ideal route between two locations.\nProvide directions with real-time traffic for transit, biking, driving,\n2-wheel motorized vehicles, or walking between multiple locations.\n\n**Need Route Matrixes?** If you are interested in a route matrix, see\n[Compute Route Matrix Overview](/maps/documentation/routes/compute-route-matrix-over).\n\n**Migrating?** If you are migrating from the Distance Matrix API (Legacy),\nsee migration instructions starting with\n[Why migrate to the Routes API](/maps/documentation/routes/migrate-routes-why).\n\nWhy use Compute Routes\n----------------------\n\nWith Compute Routes, with a wide\nrange of route details you can route your vehicles or packages according to\nyour preferences while optimizing for cost and quality.\n\nWhat you can do with Compute Routes?\n------------------------------------\n\nWith the Routes API `Compute Routes` method, you can\ndo the following things:\n\n- **Get directions for different ways to travel**, and for a single or\n multiple destinations:\n\n - Modes of transportation: transit, driving, two-wheel vehicles,\n walking, or bicycling.\n\n - A series of waypoints that you can optimize for the most efficient\n order in which to travel to them.\n\n- **Use multiple ways to specify origins, destinations, and waypoints**:\n\n - Text strings. For example: \"Chicago, IL\", \"Darwin, NT, Australia\", \"1800\n Amphitheatre Parkway, Mountain View, CA 94043\", or \"CWF6+FWX Mountain\n View, California\"\n\n - Place IDs\n\n - Latitude and longitude coordinates, optionally with vehicle heading\n\n- **Fine-tune your route options** based on your needs and goals:\n\n - Select fuel or energy-efficient routes for your vehicle's engine type:\n Diesel, Electric, Hybrid, Gas. For more information, see\n [Get an eco-friendly route](/maps/documentation/routes/eco-routes#request_an_eco-friendly_route).\n\n - Set fine-grained options for traffic calculation, letting you make\n quality versus latency trade off decisions. For details, see\n [Specify how and if to include traffic data](/maps/documentation/routes/config_trade_offs).\n\n - Set vehicle heading (direction of travel) and side-of-road information\n for waypoints to increase ETA accuracy. For details, see\n [Specify vehicle heading and side of road](/maps/documentation/routes/location_modifiers).\n\n - Specify pass-through versus terminal locations and safe stopover\n locations. For details, see [Set a stop along a route](/maps/documentation/routes/stop_over) and\n [Set a point for a route to pass through](/maps/documentation/routes/pass-through).\n\n - Request toll information, along with route distance and ETA. For\n details, see\n [Calculate toll fees for a route](/maps/documentation/routes/calculate_toll_fees).\n\n- **Control your latency and quality** by requesting only the data you need\n using a field mask, which helps you avoid unnecessary processing time and\n higher request billing rates. For details, see\n [Choose what information to return](/maps/documentation/routes/choose_fields).\n\nHow Compute Routes works\n------------------------\n\nThe Routes API `ComputeRoutes` method accepts an HTTP POST request with\na JSON request body that contains the request details. Required are an origin,\ndestination, `travelMode`, and a field mask to specify which fields to return. \n\n#### Example\n\n```json\ncurl -X POST -d '{\n \"origin\": {\n \"address\": \"1800 Amphitheatre Parkway, Mountain View, CA 94043\"\n },\n \"destination\": {\n \"address\": \"Sloat Blvd &, Upper Great Hwy, San Francisco, CA 94132\"\n },\n \"travelMode\": \"DRIVE\"\n }' \\\n -H 'Content-Type: application/json' -H 'X-Goog-Api-Key: YOUR_API_KEY' \\\n -H 'X-Goog-FieldMask: routes.duration,routes.distanceMeters' \\\n 'https://routes.googleapis.com/directions/v2:computeRoutes'\n```\n\nThe service then calculates the requested route, and returns the fields you've\nrequested.\n\n### Resources\n\nThe following table summarizes the resources available through the\nRoutes API Compute Routes method,\nalong with the data it returns.\n\n\u003cbr /\u003e\n\n| Data resources | Data returned | Return format |\n|----------------------------------------------------------------------|-----------------------------------------------------------------------------------|---------------|\n| [ComputeRoutes](/maps/documentation/routes/compute_route_directions) | Returns routes, legs, and steps for a route, with alternate routes, if requested. | JSON |\n\n\u003cbr /\u003e\n\n### How to use Compute Routes\n\n|---|---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Get set up** | Start with [Set up your Google Cloud project](/maps/documentation/routes/cloud-setup) and complete the setup instructions that follow. |\n| 2 | **Understand how the Routes API bills** | For information, see [Usage and billing](/maps/documentation/routes/usage-and-billing). |\n| 3 | **Compute a route and review the response** | For more information, see [Get a route](/maps/documentation/routes/compute_route_directions) and [Review the route responses](/maps/documentation/routes/understand-route-response). |\n\n### Available client libraries\n\nFor a list of the available client libraries for\nCompute Routes, see\n[Client libraries](/maps/documentation/routes/client-libraries).\n\nWhat's next\n-----------\n\n- [Get a route](/maps/documentation/routes/compute_route_directions)\n- [Available route options](/maps/documentation/routes/route-opt)\n- [Choose what information to return](/maps/documentation/routes/choose_fields)\n- [Migrate from Directions API (Legacy)](/maps/documentation/routes/migrate-routes)\n- [Migrate from the Routes API preview to GA](/maps/documentation/routes/migrate-routes-preview)"]]