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 Mã hoá địa lý là một dịch vụ cung cấp tính năng mã hoá địa lý và mã hoá địa lý ngược của địa chỉ.
Mã hoá địa lý là quá trình chuyển đổi địa chỉ (chẳng hạn như địa chỉ đường phố) thành toạ độ địa lý (chẳng hạn như vĩ độ và kinh độ). Bạn có thể sử dụng toạ độ này để đặt điểm đánh dấu trên bản đồ hoặc định vị bản đồ.
Mã hoá địa lý ngược là quá trình chuyển đổi toạ độ địa lý thành địa chỉ mà con người có thể đọc được.
Bạn cũng có thể sử dụng API Mã hoá địa lý để tìm địa chỉ cho một mã địa điểm nhất định.
Yêu cầu và phản hồi mẫu
Bạn truy cập vào API Mã hoá địa lý thông qua giao diện HTTP. Sau đây là ví dụ về các yêu cầu mã hoá địa lý và mã hoá địa lý ngược.
Yêu cầu và phản hồi về việc mã hoá địa lý (truy vấn vĩ độ/kinh độ)
Ví dụ sau yêu cầu vĩ độ và kinh độ của "1600 Amphitheatre Parkway, Mountain View, CA" và chỉ định rằng đầu ra phải ở định dạng JSON.
Bạn có thể kiểm thử điều này bằng cách nhập URL vào trình duyệt web (nhớ thay thế YOUR_API_KEY bằng khoá API thực tế của bạn). Nội dung phản hồi bao gồm vĩ độ và kinh độ của địa chỉ.
Dưới đây là phản hồi dịch địa lý mẫu, ở định dạng JSON:
{"results":[{"address_components":[{"long_name":"1600","short_name":"1600","types":["street_number"]},{"long_name":"Amphitheatre Parkway","short_name":"Amphitheatre Pkwy","types":["route"]},{"long_name":"Mountain View","short_name":"Mountain View","types":["locality","political"]},{"long_name":"Santa Clara County","short_name":"Santa Clara County","types":["administrative_area_level_2","political"]},{"long_name":"California","short_name":"CA","types":["administrative_area_level_1","political"]},{"long_name":"United States","short_name":"US","types":["country","political"]},{"long_name":"94043","short_name":"94043","types":["postal_code"]}],"formatted_address":"1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA","geometry":{"location":{"lat":37.4267861,"lng":-122.0806032},"location_type":"ROOFTOP","viewport":{"northeast":{"lat":37.4281350802915,"lng":-122.0792542197085},"southwest":{"lat":37.4254371197085,"lng":-122.0819521802915}}},"place_id":"ChIJtYuu0V25j4ARwu5e4wwRYgE","plus_code":{"compound_code":"CWC8+R3 Mountain View, California, United States","global_code":"849VCWC8+R3"},"types":["street_address"]}],"status":"OK"}
Yêu cầu và phản hồi mã hoá địa lý ngược (tra cứu địa chỉ)
Ví dụ sau yêu cầu địa chỉ tương ứng với vĩ độ/kinh độ nhất định ở Brooklyn, New York, Hoa Kỳ. Phương thức này chỉ định rằng đầu ra phải ở định dạng JSON.
Bạn có thể kiểm tra điều này bằng cách nhập URL vào trình duyệt web (nhớ thay thế "YOUR_API_KEY" bằng khoá API thực tế của bạn). Phản hồi bao gồm địa chỉ mà con người đọc được cho vị trí vĩ độ và kinh độ.
Dưới đây là phản hồi dịch địa lý ngược mẫu, ở định dạng JSON:
{"plus_code":{"compound_code":"P27Q+MC New York, NY, USA","global_code":"87G8P27Q+MC"},"results":[{"address_components":[{"long_name":"279","short_name":"279","types":["street_number"]},{"long_name":"Bedford Avenue","short_name":"Bedford Ave","types":["route"]},{"long_name":"Williamsburg","short_name":"Williamsburg","types":["neighborhood","political"]},{"long_name":"Brooklyn","short_name":"Brooklyn","types":["political","sublocality","sublocality_level_1"]},{"long_name":"Kings County","short_name":"Kings County","types":["administrative_area_level_2","political"]},{"long_name":"New York","short_name":"NY","types":["administrative_area_level_1","political"]},{"long_name":"United States","short_name":"US","types":["country","political"]},{"long_name":"11211","short_name":"11211","types":["postal_code"]}],"formatted_address":"279 Bedford Ave, Brooklyn, NY 11211, USA","geometry":{"location":{"lat":40.7142484,"lng":-73.9614103},"location_type":"ROOFTOP","viewport":{"northeast":{"lat":40.71559738029149,"lng":-73.9600613197085},"southwest":{"lat":40.71289941970849,"lng":-73.96275928029151}}},"place_id":"ChIJT2x8Q2BZwokRpBu2jUzX3dE","plus_code":{"compound_code":"P27Q+MC Brooklyn, New York, United States","global_code":"87G8P27Q+MC"},"types":["bakery","cafe","establishment","food","point_of_interest","store"]},...Additionalresultstruncatedinthisexample[]...],"status":"OK"}
Bắt đầu lập trình bằng thư viện ứng dụng của chúng tôi
Thư viện ứng dụng giúp bạn phát triển bằng API dịch vụ web của Google Maps dễ dàng hơn bằng cách cung cấp các phương thức triển khai gốc, đơn giản cho các tác vụ phổ biến, chẳng hạn như xác thực, điều tiết yêu cầu và thử lại tự động. API Mã hoá địa lý có sẵn trong Ứng dụng Java, ứng dụng Python, ứng dụng Go và ứng dụng Node.js cho Dịch vụ Google Maps.
Xác thực, hạn mức, giá và chính sách
Xác thực
Để sử dụng API Mã hoá địa lý, trước tiên, bạn phải bật API này và lấy thông tin xác thực thích hợp. Để biết thêm thông tin, hãy xem bài viết Bắt đầu sử dụng Google Maps Platform.
Hạn mức và giá
Xem trang hạn mức sử dụng và thanh toán để biết thông tin chi tiết về hạn mức và mức giá được đặt cho API Mã hoá địa lý.
Hướng dẫn dành cho nhà phát triển về API Mã hoá địa lý mô tả dịch vụ web API Mã hoá địa lý. API này dành cho các nhà phát triển trang web và ứng dụng di động muốn sử dụng dữ liệu mã hoá địa lý trong bản đồ do một trong các API của Nền tảng Google Maps cung cấp.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-08-16 UTC."],[[["\u003cp\u003eThe Geocoding API converts addresses into geographic coordinates (geocoding) and vice versa (reverse geocoding).\u003c/p\u003e\n"],["\u003cp\u003eYou need a Google Cloud project with billing enabled and the Geocoding API enabled before using the service.\u003c/p\u003e\n"],["\u003cp\u003eAccess the Geocoding API through HTTP requests, specifying the address or coordinates and desired output format.\u003c/p\u003e\n"],["\u003cp\u003eClient libraries are available for Java, Python, Go, and Node.js to simplify development with the API.\u003c/p\u003e\n"],["\u003cp\u003eUsage of the Geocoding API is subject to quotas, pricing, and policies outlined in the documentation.\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| **Before you begin:** Before you start using the Geocoding API, you need a project with a billing account and the Geocoding API enabled. We recommend creating multiple Project Owners and Billing Administrators, so that you'll always have someone with these roles available to your team. To learn more, see [Set up in Cloud console](/maps/documentation/geocoding/cloud-setup).\n\nThe Geocoding API is a service that provides geocoding and reverse geocoding\nof addresses.\n| This service is also available as part of the client-side [Google Maps JavaScript\n| API](/maps/documentation/javascript/geocoding), or for server-side use with the [Java Client,\n| Python Client, Go Client and Node.js Client for Google Maps Services](/maps/documentation/geocoding/client-library).\n\n**Geocoding** is the process of converting addresses (like a street address)\ninto geographic coordinates (like latitude and longitude), which you can use to place markers\non a map, or position the map.\n\n**Reverse geocoding** is the process of converting geographic coordinates\ninto a human-readable address.\n\nYou can also use the Geocoding API to find the address for a\ngiven [place ID](/maps/documentation/geocoding/requests-places-geocoding).\n\nSample request and response\n\nYou access the Geocoding API through an HTTP interface. Following\nare examples of geocoding and [reverse geocoding](#reverse) requests.\n\nGeocoding request and response (latitude/longitude lookup)\n\nThe following example requests the latitude and longitude of \"1600 Amphitheatre\nParkway, Mountain View, CA\", and specifies that the output must be in JSON format. \n\n```carbon\nhttps://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&key=YOUR_API_KEY\n```\n\nYou can test this by entering the URL into your web browser (be sure to replace\n`YOUR_API_KEY` with [your actual API key](/maps/documentation/geocoding/get-api-key)).\nThe response includes the latitude and longitude of the address.\n\nView the [developer's guide](/maps/documentation/geocoding/overview)\nfor more information about\n[building geocoding request URLs](/maps/documentation/geocoding/overview#geocoding-requests) and\n[available parameters](/maps/documentation/geocoding/overview#geocoding)\nand [understanding the response](/maps/documentation/geocoding/overview#geocoding-requests).\n\nBelow is a sample geocoding response, in JSON: \n\n```carbon\n{\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"1600\",\n \"short_name\" : \"1600\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Amphitheatre Parkway\",\n \"short_name\" : \"Amphitheatre Pkwy\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Mountain View\",\n \"short_name\" : \"Mountain View\",\n \"types\" : [ \"locality\", \"political\" ]\n },\n {\n \"long_name\" : \"Santa Clara County\",\n \"short_name\" : \"Santa Clara County\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"California\",\n \"short_name\" : \"CA\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"United States\",\n \"short_name\" : \"US\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"94043\",\n \"short_name\" : \"94043\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 37.4267861,\n \"lng\" : -122.0806032\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 37.4281350802915,\n \"lng\" : -122.0792542197085\n },\n \"southwest\" : {\n \"lat\" : 37.4254371197085,\n \"lng\" : -122.0819521802915\n }\n }\n },\n \"place_id\" : \"ChIJtYuu0V25j4ARwu5e4wwRYgE\",\n \"plus_code\" : {\n \"compound_code\" : \"CWC8+R3 Mountain View, California, United States\",\n \"global_code\" : \"849VCWC8+R3\"\n },\n \"types\" : [ \"street_address\" ]\n }\n ],\n \"status\" : \"OK\"\n}\n```\n\nReverse geocoding request and response (address lookup)\n\nThe following example requests the address corresponding to a given latitude/longitude\nin Brooklyn, NY, USA. It specifies that the output must be in JSON format. \n\n```scdoc\nhttps://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY\n```\n\nYou can test this by entering the URL into your web browser (be sure to replace\n'YOUR_API_KEY' with [your actual API key](#get-a-key)).\nThe response includes a human-readable address for the latitude and longitude\nlocation.\n\nView the [developer's guide](/maps/documentation/geocoding/overview)\nfor more information about\n[building reverse geocoding request URLs](/maps/documentation/geocoding/overview#GeocodingRequests) and\n[available parameters](/maps/documentation/geocoding/overview#ReverseGeocoding)\nand [understanding the response](/maps/documentation/geocoding/overview#reverse-response).\n\nBelow is a sample reverse geocoding response, in JSON: \n\n```carbon\n{\n \"plus_code\" : {\n \"compound_code\" : \"P27Q+MC New York, NY, USA\",\n \"global_code\" : \"87G8P27Q+MC\"\n },\n \"results\" : [\n {\n \"address_components\" : [\n {\n \"long_name\" : \"279\",\n \"short_name\" : \"279\",\n \"types\" : [ \"street_number\" ]\n },\n {\n \"long_name\" : \"Bedford Avenue\",\n \"short_name\" : \"Bedford Ave\",\n \"types\" : [ \"route\" ]\n },\n {\n \"long_name\" : \"Williamsburg\",\n \"short_name\" : \"Williamsburg\",\n \"types\" : [ \"neighborhood\", \"political\" ]\n },\n {\n \"long_name\" : \"Brooklyn\",\n \"short_name\" : \"Brooklyn\",\n \"types\" : [ \"political\", \"sublocality\", \"sublocality_level_1\" ]\n },\n {\n \"long_name\" : \"Kings County\",\n \"short_name\" : \"Kings County\",\n \"types\" : [ \"administrative_area_level_2\", \"political\" ]\n },\n {\n \"long_name\" : \"New York\",\n \"short_name\" : \"NY\",\n \"types\" : [ \"administrative_area_level_1\", \"political\" ]\n },\n {\n \"long_name\" : \"United States\",\n \"short_name\" : \"US\",\n \"types\" : [ \"country\", \"political\" ]\n },\n {\n \"long_name\" : \"11211\",\n \"short_name\" : \"11211\",\n \"types\" : [ \"postal_code\" ]\n }\n ],\n \"formatted_address\" : \"279 Bedford Ave, Brooklyn, NY 11211, USA\",\n \"geometry\" : {\n \"location\" : {\n \"lat\" : 40.7142484,\n \"lng\" : -73.9614103\n },\n \"location_type\" : \"ROOFTOP\",\n \"viewport\" : {\n \"northeast\" : {\n \"lat\" : 40.71559738029149,\n \"lng\" : -73.9600613197085\n },\n \"southwest\" : {\n \"lat\" : 40.71289941970849,\n \"lng\" : -73.96275928029151\n }\n }\n },\n \"place_id\" : \"ChIJT2x8Q2BZwokRpBu2jUzX3dE\",\n \"plus_code\" : {\n \"compound_code\" : \"P27Q+MC Brooklyn, New York, United States\",\n \"global_code\" : \"87G8P27Q+MC\"\n },\n \"types\" : [\n \"bakery\",\n \"cafe\",\n \"establishment\",\n \"food\",\n \"point_of_interest\",\n \"store\"\n ]\n },\n\n ... Additional results truncated in this example[] ...\n\n ],\n \"status\" : \"OK\"\n}\n```\n\nStart coding with our client libraries\n\nClient libraries make\ndeveloping with the Google Maps web service APIs easier by providing simple,\nnative implementations of common tasks, such as authentication, request\nthrottling and automatic retry. The Geocoding API is available\nin the\n[Java Client,\nPython Client, Go Client and Node.js Client for Google Maps Services](/maps/documentation/geocoding/client-library).\n\nAuthentication, quotas, pricing, and policies\n\nAuthentication\n\nTo use the Geocoding API, you must first enable the API\nand obtain the proper authentication credentials. For more information, see\n[Get Started with Google Maps Platform](https://developers.google.com/maps/get-started).\n\nQuotas and pricing\n\nReview the [usage and billing](/maps/documentation/geocoding/usage-and-billing)\npage for details on the quotas and pricing set for the Geocoding API.\n\nPolicies\n\nUse of the Geocoding API must be in accordance with the\n[API policies](/maps/documentation/geocoding/policies).\n\nLearn more\n\nThere's more you can do with the Geocoding API. See the\n[Geocoding API developer guide](/maps/documentation/geocoding/overview) for additional demos,\nexamples, available parameters, status codes and error messages, and other details.\n\nThe [Geocoding API developer guide](/maps/documentation/geocoding/overview) describes the\nGeocoding API web service. It is intended for website and mobile developers\nwho want to use geocoding data within maps provided by one of the Google Maps Platform\nAPIs."]]