Di chuyển từ bản phát hành Xem trước
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Nhà phát triển ở Khu vực kinh tế Châu Âu (EEA)
Routes API được phát hành dưới dạng Bản dùng thử công khai (trước khi phát hành công khai) vào tháng 9 năm 2022. Các Sản phẩm/dịch vụ ở giai đoạn trước khi phát hành rộng rãi tuân theo Điều khoản dành riêng cho dịch vụ của Nền tảng Google Maps.
Để biết thêm thông tin, hãy xem nội dung mô tả về giai đoạn ra mắt.
Phần này mô tả cách di chuyển một ứng dụng từ bản phát hành Xem trước sang bản phát hành GA.
Các tính năng mới được thêm vào bản phát hành GA
Bản phát hành GA bổ sung các tính năng mới sau đây mà không có trong bản Xem trước:
Ngoài mã địa điểm và toạ độ vĩ độ/kinh độ, giờ đây, bạn có thể chỉ định một vị trí trong bản phát hành GA bằng cách sử dụng:
Chuỗi địa chỉ ("Chicago, IL" hoặc "Darwin, Lãnh thổ Bắc Úc, Úc")
Chuỗi địa chỉ thường là cách người dùng nhập địa chỉ. Tuy nhiên, trước tiên, {product_name} phải mã hoá chuỗi địa chỉ theo địa lý nội bộ để chuyển đổi chuỗi đó thành toạ độ vĩ độ/kinh độ thì mới có thể tính toán tuyến đường.
Ngoài ra, chúng tôi đã thêm chế độ hỗ trợ cho tham số yêu cầu regionCode
. Tham số này cho phép bạn chỉ định trả về kết quả được mã hoá địa lý cho một khu vực địa lý cụ thể.
Plus Codes
Plus Code giống như địa chỉ đường phố dành cho những người hoặc địa điểm không có địa chỉ thực. Thay vì địa chỉ có tên đường và số nhà, Mã cộng được dựa trên vĩ độ và kinh độ, đồng thời được hiển thị dưới dạng số và chữ cái.
Phản hồi tính toán tuyến đường hiện chứa mảng geocodingResults
. Đối với mọi vị trí trong yêu cầu (điểm xuất phát, điểm đến hoặc điểm tham chiếu trung gian) được chỉ định là một chuỗi địa chỉ hoặc là một Mã cộng, API sẽ thực hiện một thao tác tra cứu mã địa điểm. Mỗi phần tử của mảng này chứa mã địa điểm tương ứng với một vị trí cùng với siêu dữ liệu bổ sung về vị trí đó. Các vị trí trong yêu cầu được chỉ định dưới dạng mã địa điểm hoặc dưới dạng toạ độ vĩ độ/kinh độ sẽ bị bỏ qua.
Thay đổi đối với các tính năng Xem trước hiện có
Giờ đây, bạn phải bật rõ ràng các tính năng sau trong GA bằng cách thêm trường mảng extraComputations
mới vào yêu cầu:
Trong bản phát hành Xem trước, bạn đã sử dụng mặt nạ trường để chỉ định trả về thông tin cho các tính năng này trong phản hồi. Giờ đây, bạn phải:
- Đặt tham số yêu cầu mảng
extraComputations
mới để bật các tính năng này.
- Đặt một mặt nạ trường để chỉ định trả về thông tin trong phản hồi.
Bạn cần biết điều gì?
Các trường sau đây sẽ không còn được đưa vào phản hồi computeRouteMatrix nữa, trừ phi bạn bật một cách rõ ràng bằng cách đặt extraComputations
:
travelAdvisory.tollInfo
(Thông tin về phí cầu đường)
Các trường sau đây sẽ không còn được đưa vào phản hồi computeRoutes nữa, trừ phi bạn bật một cách rõ ràng bằng cách đặt extraComputations
:
routes.legs.travelAdvisory.tollInfo
(Thông tin về phí cầu đường)
routes.travelAdvisory.tollInfo
(Thông tin về phí cầu đường)
routes.travelAdvisory.fuelConsumptionMicroliters
(Mức tiêu thụ nhiên liệu)
routes.travelAdvisory.speedReadingIntervals
(Tình trạng giao thông trên một đường nhiều đoạn)
routes.legs.travelAdvisory.speedReadingIntervals
(Tình trạng giao thông trên một đường nhiều đoạn)
Việc bạn cần làm
Để nhận các trường phản hồi cho thông tin về phí cầu đường, mức tiêu thụ nhiên liệu hoặc lưu lượng truy cập trên một đường nhiều đoạn, bạn phải đặt trường mảng yêu cầu mới, extraComputations
, để bao gồm một hoặc nhiều giá trị sau:
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-22 UTC.
[null,null,["Cập nhật lần gần đây nhất: 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\"`."]]