ย้ายข้อมูลจากเวอร์ชันตัวอย่าง
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
นักพัฒนาแอปในเขตเศรษฐกิจยุโรป (EEA)
Routes API เปิดตัวเป็นเวอร์ชันตัวอย่างแบบสาธารณะ (ก่อน GA) ในเดือนกันยายน 2022
ข้อเสนอก่อนเปิดให้ใช้งานทั่วไปอยู่ภายใต้ข้อกำหนดเฉพาะบริการของ Google Maps Platform
ดูข้อมูลเพิ่มเติมได้ที่คำอธิบายเกี่ยวกับระยะการเปิดตัว
ส่วนนี้จะอธิบายวิธีย้ายข้อมูลแอปจากรุ่นตัวอย่างไปยังรุ่น GA
ฟีเจอร์ใหม่ที่เพิ่มลงในรุ่น GA
การเปิดตัว GA ได้เพิ่มฟีเจอร์ใหม่ต่อไปนี้ซึ่งไม่ได้รวมอยู่ใน
เวอร์ชันตัวอย่าง
นอกจากรหัสสถานที่และพิกัดละติจูด/ลองจิจูดแล้ว ตอนนี้คุณยังระบุสถานที่ในรุ่น GA ได้ด้วยการใช้ข้อมูลต่อไปนี้
สตริงที่อยู่ ("ชิคาโก รัฐอิลลินอยส์" หรือ
"ดาร์วิน นอร์เทิร์นเทร์ริทอรี ออสเตรเลีย")
โดยทั่วไปแล้ว สตริงที่อยู่คือวิธีที่ผู้ใช้ป้อนที่อยู่ อย่างไรก็ตาม {product_name} ต้องเข้ารหัสที่อยู่ภายในก่อนเพื่อแปลงเป็นพิกัดละติจูด/ลองจิจูดก่อนจึงจะคำนวณเส้นทางได้
นอกจากนี้ เรายังได้เพิ่มการรองรับพารามิเตอร์คำขอ regionCode
ซึ่งช่วยให้คุณระบุให้แสดงผลลัพธ์ที่แปลงเป็นพิกัดภูมิศาสตร์สำหรับภูมิภาคที่เฉพาะเจาะจงได้
โค้ด Plus
Plus Codes เป็นเหมือนที่อยู่ของผู้คนหรือสถานที่ซึ่งไม่มีที่อยู่อย่างเป็นทางการ Plus Codes ไม่ใช่ข้อมูลที่อยู่ที่ประกอบด้วยชื่อถนนและบ้านเลขที่ แต่จะเป็นชุดตัวเลขและตัวอักษรที่สร้างขึ้นโดยอิงจากพิกัดละติจูดและลองจิจูด
ตอนนี้การตอบกลับของเส้นทางการคำนวณมีอาร์เรย์
geocodingResults
แล้ว สำหรับสถานที่ตั้งทุกแห่งในคำขอ (ต้นทาง
ปลายทาง หรือจุดแวะพักกลางทาง) ที่ระบุเป็นสตริง
ที่อยู่หรือเป็นโค้ด Plus API จะทำการค้นหารหัสสถานที่ แต่ละ
องค์ประกอบของอาร์เรย์นี้มีรหัสสถานที่ที่สอดคล้องกับสถานที่ตั้ง
พร้อมด้วยข้อมูลเมตาเพิ่มเติมเกี่ยวกับสถานที่ตั้ง ระบบจะละเว้นสถานที่ตั้งในคำขอ
ที่ระบุเป็นรหัสสถานที่หรือเป็นพิกัดละติจูด/ลองจิจูด
การเปลี่ยนแปลงฟีเจอร์เวอร์ชันตัวอย่างที่มีอยู่
ตอนนี้คุณต้องเปิดใช้ฟีเจอร์ต่อไปนี้อย่างชัดเจนใน GA โดย
เพิ่มฟิลด์อาร์เรย์ใหม่ extraComputations
ลงในคำขอ
ในรุ่นตัวอย่าง คุณใช้ฟิลด์มาสก์เพื่อระบุให้
แสดงข้อมูลสำหรับฟีเจอร์เหล่านี้ในการตอบกลับ ตอนนี้คุณต้องทำทั้ง 2 อย่างต่อไปนี้
- ตั้งค่า
extraComputations
พารามิเตอร์คำขออาร์เรย์ใหม่เพื่อเปิดใช้ฟีเจอร์เหล่านี้
- ตั้งค่ามาสก์ฟิลด์เพื่อระบุให้แสดงข้อมูลในการตอบกลับ
สิ่งที่ต้องทราบ
ระบบจะไม่รวมฟิลด์ต่อไปนี้ไว้ในการตอบกลับของ computeRouteMatrix
อีกต่อไป เว้นแต่จะเปิดใช้โดยชัดแจ้งด้วยการตั้งค่า extraComputations
travelAdvisory.tollInfo
(ข้อมูลค่าผ่านทาง)
ระบบจะไม่รวมฟิลด์ต่อไปนี้ไว้ใน
การตอบกลับของ computeRoutes
เว้นแต่จะเปิดใช้โดยชัดแจ้งด้วยการตั้งค่า extraComputations
routes.legs.travelAdvisory.tollInfo
(ข้อมูลค่าผ่านทาง)
routes.travelAdvisory.tollInfo
(ข้อมูลค่าผ่านทาง)
routes.travelAdvisory.fuelConsumptionMicroliters
(ปริมาณการใช้เชื้อเพลิง)
routes.travelAdvisory.speedReadingIntervals
(การจราจรบนเส้นประกอบ)
routes.legs.travelAdvisory.speedReadingIntervals
(การจราจรบนเส้นประกอบ)
สิ่งที่ต้องทำ
หากต้องการรับฟิลด์การตอบกลับสำหรับข้อมูลค่าผ่านทาง การสิ้นเปลืองเชื้อเพลิง หรือการจราจรใน
Polyline คุณต้องตั้งค่าฟิลด์อาร์เรย์คำขอใหม่ extraComputations
ให้
รวมค่าต่อไปนี้อย่างน้อย 1 ค่า
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-22 UTC
[null,null,["อัปเดตล่าสุด 2025-07-22 UTC"],[[["\u003cp\u003eThe Routes API has transitioned from Preview to General Availability (GA), introducing new features and changes to existing ones.\u003c/p\u003e\n"],["\u003cp\u003eYou can now specify locations using address strings and Plus Codes in addition to place IDs and coordinates.\u003c/p\u003e\n"],["\u003cp\u003eToll info, fuel consumption, and traffic on a polyline now require explicit enablement using the \u003ccode\u003eextraComputations\u003c/code\u003e field in requests.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egeocodingResults\u003c/code\u003e array has been added to the response, providing place IDs and metadata for locations specified as address strings or Plus Codes.\u003c/p\u003e\n"],["\u003cp\u003eExisting implementations relying on implicit inclusion of toll info, fuel consumption, or traffic on a polyline data need to be updated to utilize the \u003ccode\u003eextraComputations\u003c/code\u003e field.\u003c/p\u003e\n"]]],["The Routes API's GA release introduces new location specification options, including address strings and Plus Codes, and includes a `geocodingResults` array in the response. To enable toll info, fuel consumption, and traffic on a polyline, users must now set the `extraComputations` array in their requests. `extraComputations` values are \"TOLLS\", \"FUEL_CONSUMPTION\", and \"TRAFFIC_ON_POLYLINE\". The field mask must still be used. Certain fields will be omitted in the response unless enabled by `extraComputations`.\n"],null,["# Migrate from the Preview release\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\nThe Routes API was released as a public Preview (pre-GA) in September of\n2022. Pre-GA Offerings are covered by the [Google Maps Platform Service Specific\nTerms](https://cloud.google.com/maps-platform/terms/maps-service-terms).\nFor more information, see the [launch stage descriptions](/maps/launch-stages).\n\nThis section describes how to migrate an app from the Preview release to the GA\nrelease.\n\nNew features added to the GA release\n------------------------------------\n\nThe GA release adds the following new features that were not included in the\nPreview:\n\n- Along with place IDs and latitude/longitude coordinates, you can now\n [specify a location](/maps/documentation/routes/specify_location) in the GA release by using:\n\n - [Address strings](/maps/documentation/routes/specify_location#text_string) (\"Chicago, IL\" or\n \"Darwin, NT, Australia\")\n\n Address strings are often how a user inputs an address. However,\n {product_name} must first geocode the address string internally to convert\n it to latitude/longitude coordinates before it can calculate a route.\n\n In addition, support for the `regionCode` request parameter has been\n added, which lets you specify to return geocoded results for a specific\n geographic region.\n - [Plus Codes](/maps/documentation/routes/specify_location#plus_code)\n\n Plus Codes are like street addresses for people or places that don't\n have an actual address. Instead of addresses with street names and\n numbers, Plus Codes are based on latitude and longitude, and are\n displayed as numbers and letters.\n- The [compute routes response](/maps/documentation/routes/understand-route-response) now contains the\n `geocodingResults` array. For every location in the request (origin,\n destination, or intermediate waypoint) that was specified as an **address\n string** or as a **Plus code**, the API performs a place ID lookup. Each\n element of this array contains the place ID corresponding to a location\n along with additional metadata about the location. Locations in the request\n specified as a place ID or as latitude/longiiture coordinates are ignored.\n\nChanges to existing Preview features\n------------------------------------\n\nYou must now explicitly enable the following features in the GA by\nadding the new array `extraComputations` field to the request:\n\n- [Toll info](/maps/documentation/routes/calculate_toll_fees)\n\n- [Fuel consumption](/maps/documentation/routes/eco-routes)\n\n- [Traffic on a polyline](/maps/documentation/routes/traffic_on_polylines)\n\nIn the Preview release, you used a [field mask](/maps/documentation/routes/choose_fields) to specify to\nreturn information for these features in the response. Now, you must both:\n\n- Set the new `extraComputations` array request parameter to enable these features.\n- Set a field mask to specify to return the information in the response.\n\n### What do I need to know?\n\nThe following fields will no longer be included in\n[computeRouteMatrix responses](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRouteMatrix#response-body)\nunless explicitly enabled by setting `extraComputations`:\n\n- `travelAdvisory.tollInfo` (Toll info)\n\nThe following fields will no longer be included in\n[computeRoutes responses](/maps/documentation/routes/reference/rest/v2/TopLevel/computeRoutes#response-body)\nunless explicitly enabled by setting `extraComputations`:\n\n- `routes.legs.travelAdvisory.tollInfo`(Toll info)\n- `routes.travelAdvisory.tollInfo`(Toll info)\n- `routes.travelAdvisory.fuelConsumptionMicroliters`(Fuel consumption)\n- `routes.travelAdvisory.speedReadingIntervals`(Traffic on a polyline)\n- `routes.legs.travelAdvisory.speedReadingIntervals`(Traffic on a polyline)\n\n### What do I need to do?\n\nTo receive the response fields for toll info, fuel consumption, or traffic on a\npolyline, you must set the new request array field, `extraComputations`, to\ninclude one or more of the following values:\n\n- To receive [toll info](/maps/documentation/routes/calculate_toll_fees), set the new\n `extraComputations` array field to `\"TOLLS\"`.\n\n- To receive [fuel consumption](/maps/documentation/routes/eco-routes), set the new `extraComputations`\n array field to `\"FUEL_CONSUMPTION\"`.\n\n- To receive [traffic information on polylines](/maps/documentation/routes/traffic_on_polylines), set the\n new `extraComputations` array field to `\"TRAFFIC_ON_POLYLINE\"`."]]