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)
API Địa chỉ được mã hoá là một dịch vụ chấp nhận một địa điểm dưới dạng địa chỉ, toạ độ vĩ độ và kinh độ hoặc Mã địa điểm. Phương thức này chuyển đổi địa chỉ thành toạ độ vĩ độ và kinh độ cũng như Mã địa điểm, hoặc chuyển đổi toạ độ vĩ độ và kinh độ hoặc Mã địa điểm thành địa chỉ.
Lý do sử dụng API Mã hoá địa lý
Sử dụng API Mã hoá địa lý cho trang web hoặc ứng dụng di động khi bạn muốn sử dụng dữ liệu mã hoá địa lý trong bản đồ do một trong các API Nền tảng Google Maps cung cấp.
Với API Mã hoá địa lý, bạn có thể sử dụng địa chỉ để đặt điểm đánh dấu trên bản đồ hoặc chuyển đổi điểm đánh dấu trên bản đồ thành địa chỉ. Dịch vụ này được thiết kế để mã hoá địa lý các địa chỉ tĩnh, được xác định trước nhằm đặt nội dung ứng dụng trên bản đồ.
Những việc bạn có thể làm với API Địa chỉ
Bạn có thể sử dụng API Mã hoá địa lý để lấy dữ liệu mã hoá địa lý cho một hoặc nhiều địa chỉ hoặc địa điểm, bao gồm:
Toạ độ địa lý của địa chỉ.
Địa chỉ cho các tập hợp toạ độ vĩ độ và kinh độ.
Địa chỉ cho mã địa điểm.
Bạn có thể kiểm soát vị trí xuất hiện kết quả và giới hạn kết quả ở một khu vực, hạt hoặc mã bưu chính cụ thể.
Cách hoạt động của Geocoding API
Geocoding API thực hiện cả việc mã hoá địa lý và mã hoá địa lý ngược:
Báo cáo địa lý: Chuyển đổi các địa chỉ như "1600 Amphitheatre Parkway, Mountain View, CA" thành toạ độ vĩ độ và kinh độ hoặc mã nhận dạng Địa điểm. Bạn có thể sử dụng các toạ độ này để đặt điểm đánh dấu trên bản đồ, hoặc để căn giữa hoặc định vị lại bản đồ trong khung hiển thị.
Mã hoá địa lý ngược: Chuyển đổi toạ độ vĩ độ/kinh độ hoặc Mã địa điểm thành địa chỉ mà con người có thể đọc được. Bạn có thể sử dụng địa chỉ cho nhiều trường hợp, bao gồm cả giao hàng hoặc đến lấy hàng.
Bản minh hoạ sau đây sử dụng Dịch vụ mã hoá địa lý thông qua API Maps JavaScript để minh hoạ cách hoạt động của API Mã hoá địa lý. Mở bản đồ trong một thẻ riêng để xem thêm các lựa chọn và thông tin chi tiết.
Tài nguyên
Bảng sau đây tóm tắt các tài nguyên có sẵn thông qua API Địa chỉ (Geocoding API) cùng với dữ liệu mà mỗi điểm cuối trả về.
Trả về địa chỉ, thành phần địa chỉ và loại địa chỉ. Xem nội dung Phản hồi mã hoá địa lý ngược trong hướng dẫn về yêu cầu và phản hồi mã hoá địa lý ngược.
Trả về địa chỉ, thành phần địa chỉ và loại địa chỉ. Xem nội dung Phản hồi mã hoá địa lý ngược trong hướng dẫn về yêu cầu và phản hồi mã hoá địa lý của địa điểm.
Sau khi có khoá API, bạn có thể bắt đầu kiểm thử API Địa chỉ được mã hoá địa lý ngay từ curl hoặc trình duyệt. Bạn cần cung cấp tham số tra cứu chính xác cho các lượt tra cứu địa chỉ hoặc thành phần. Hãy xem phần Tham số mã hoá địa lý để biết thông tin chi tiết.
3
Thử yêu cầu mã hoá địa lý ngược
Cung cấp toạ độ vĩ độ/kinh độ cùng với khoá API để lấy các thành phần địa chỉ cho địa chỉ gần nhất mà con người có thể đọc được cho vị trí đó.
Hãy xem phần Yêu cầu dịch ngược địa lý để biết thông tin chi tiết.
4
Tìm hiểu kiến thức cơ bản về phản hồi
Tất cả các điểm cuối trong API Địa chỉ được mã hoá địa lý đều trả về cùng một dữ liệu ở định dạng JSON hoặc XML.
Hãy xem phần Phản hồi về việc mã hoá địa lý để biết nội dung giải thích về dữ liệu, mã trạng thái và thông báo lỗi.
5
Tích hợp dữ liệu mã hoá địa lý vào ứng dụng của riêng bạn!
Bạn có thể sử dụng dữ liệu mã hoá địa lý để lấy địa chỉ từ các điểm đánh dấu trên bản đồ hoặc để cung cấp điểm đánh dấu trên bản đồ dựa trên địa chỉ đã biết.
Các thư viện ứng dụng hiện có
Gọi API này bằng ngôn ngữ bạn chọn thông qua một trong các thư viện ứng dụng sau:
Ứng dụng Java, Ứng dụng Python, Ứng dụng Go và Ứng dụng Node.js cho Dịch vụ Maps của Google là các thư viện ứng dụng do cộng đồng hỗ trợ, nguồn mở theo Giấy phép Apache 2.0.
Tải các tệp này xuống từ GitHub. Tại đây, bạn cũng có thể tìm thấy hướng dẫn cài đặt và mã mẫu.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-31 UTC."],[[["\u003cp\u003eThe Geocoding API converts addresses into geographic coordinates (latitude and longitude) and vice versa.\u003c/p\u003e\n"],["\u003cp\u003eThis API is ideal for placing markers on maps based on addresses and retrieving addresses from map locations for static content, not dynamic user input.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the Geocoding API to find geographic coordinates for addresses, addresses for coordinates, and addresses for Place IDs.\u003c/p\u003e\n"],["\u003cp\u003eThe API supports both geocoding (address to coordinates) and reverse geocoding (coordinates to address).\u003c/p\u003e\n"],["\u003cp\u003eClient libraries are available in Java, Python, Go, and Node.js for easy integration into your applications.\u003c/p\u003e\n"]]],[],null,["**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 Geocoding API is a service that accepts a place as an\naddress, latitude and longitude coordinates, or Place ID. It converts the\naddress into latitude and longitude coordinates and a Place ID, or converts\nlatitude and longitude coordinates or a Place ID into an address.\n| **Note** : If you only want plus codes and don't want to use an API key, you can use the [Plus codes API](https://github.com/google/open-location-code/tree/main/Documentation).\n\nWhy use the Geocoding API\n\nUse the Geocoding API for website or mobile application when you want to use\ngeocoding data within maps provided by one of the Google Maps Platform APIs.\nWith the Geocoding API, you use addresses to place markers on a map, or\nconvert a marker on a map to an address. This service is designed for geocoding\n**predefined, static addresses** for placement of application\ncontent on a map.\n| This service is **not** designed to respond directly to user\n| input. To do dynamic geocoding, for example, in a user interface, see the\n| [Maps JavaScript API\n| client geocoder](/maps/documentation/javascript/geocoding) and/or the\n| [Google Play services Location APIs](https://developer.android.com/google/play-services/location.html).\n\nWhat you can do with the Geocoding API\n\nYou can use the Geocoding API to obtain geocoding data for one or more addresses or\nplaces, including the following:\n\n- Geographic coordinates for addresses.\n- Addresses for sets of latitude and longitude coordinates.\n- Addresses for place IDs.\n\nYou can control where the results appear and constrain the results to a particular region,\ncounty, or postal code.\n\nHow the Geocoding API works\n\nThe Geocoding API does both geocoding and reverse geocoding:\n\n- [**Geocoding**](/maps/documentation/geocoding/requests-geocoding): Converts addresses such as \"1600 Amphitheatre Parkway, Mountain View, CA\" into latitude and longitude coordinates or Place IDs. You can use these coordinates to place markers on a map, or to center or reposition the map within the view frame.\n- [**Reverse geocoding**](/maps/documentation/geocoding/requests-reverse-geocoding): Converts latitude/longitude coordinates or a Place ID into a human-readable address. You can use addresses for a variety of scenarios, including deliveries or pickups.\n\nThe following demo uses the Geocoding Service through the Maps JavaScript API\nto demonstrate how the Geocoding API works. Open the map in a separate tab\nto see more options and details.\n\nResources\n\nThe following table summarizes the resources available through the\nGeocoding API along with the data each endpoint returns.\n\n| Data resources | Data returned | Return format |\n|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|\n| [Geocoding](/maps/documentation/geocoding/requests-geocoding) | Returns address, address components, and address types. See [Results](/maps/documentation/geocoding/requests-geocoding#results) in the *Geocoding request and response* guide. | - JSON - XML |\n| [Reverse geocoding](/maps/documentation/geocoding/requests-reverse-geocoding) | Returns address, address components, and address types. See [Reverse geocoding responses](/maps/documentation/geocoding/requests-reverse-geocoding#reverse-response) in the Reverse geocoding request and response guide. | - JSON - XML |\n| [Place geocoding](/maps/documentation/geocoding/requests-places-geocoding) | Returns address, address components, and address types. See [Reverse geocoding responses](/maps/documentation/geocoding/requests-places-geocoding) in the Place geocoding request and response guide. | - JSON - XML |\n| - JSON - XML |\n\nHow to use the Geocoding API\n\n|---|---------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1 | **Get set up.** | Start with [Set up your Google Cloud project](/maps/documentation/geocoding/cloud-setup) and complete the setup instructions that follow. |\n| 2 | **Try a geocoding request** | Once you have an API key, you can start testing out the Geocoding API directly from curl or a browser. You'll need to supply the correct lookup parameters for address or component lookups. See [Geocoding parameters](/maps/documentation/geocoding/requests-geocoding#geocoding-lookup) for details. |\n| 3 | **Try a reverse geocoding request** | Supply latitude/longitude coordinates along with your API key to obtain address components for the closest human-readable address for that location. See [Reverse geocoding requests](/maps/documentation/geocoding/requests-reverse-geocoding#reverse-requests) for details. |\n| 4 | **Understand response basics** | All endpoints in the Geocoding API return the same data in either JSON or XML. See [Geocoding responses](/maps/documentation/geocoding/requests-geocoding#GeocodingResponses) for an explanation of the data, status codes, and error messages. |\n| 5 | **Incorporate geocoding data into your own app!** | You can use geocoding data to obtain addresses from map markers or to supply markers on a map based on a known address. |\n\nAvailable client libraries\n\nCall this API in the language of\nyour choice through one of the following client libraries:\n\n- [Java\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-java)\n- [Python\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-python)\n- [Go Client\n for Google Maps Services](https://github.com/googlemaps/google-maps-services-go)\n- [Node.js\n Client for Google Maps Services](https://github.com/googlemaps/google-maps-services-js)\n\nThe Java Client, Python Client, Go Client and Node.js Client for Google Maps\nServices are community-supported client libraries, open sourced under the\n[Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0).\nDownload them from GitHub, where you can also find installation instructions and sample code.\n\nWhat's next\n\n- **Start using the Geocoding API** : Go to [Set up your\n Google Cloud project](/maps/documentation/geocoding/cloud-setup).\n- **Get started with sample requests and responses** : Go to [Geocoding requests and responses](/maps/documentation/geocoding/requests-geocoding)\n- **Follow best practices** : Go to [Geocoding Addresses Best\n Practices](/maps/documentation/geocoding/best-practices)."]]