Geocoding API 總覽
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Geocoding API 是一項服務,可接受地點為地址、經緯度座標或地點 ID。將地址轉換為經緯度座標和地點 ID,或將經緯度座標或地點 ID 轉換為地址。
使用 Geocoding API 的原因
如要在 Google 地圖平台 API 提供的地圖中使用地理編碼資料,請為網站或行動應用程式使用 Geocoding API。您可以使用 Geocoding API,將地址用於在地圖上放置標記,或將地圖上的標記轉換為地址。這項服務專門用於將預先定義的靜態地址進行地理編碼,以便將應用程式內容放置在地圖上。
Geocoding API 的用途
您可以使用 Geocoding API 取得一或多個地址或地點的地理編碼資料,包括:
- 地址的地理座標。
- 經緯度座標組合的地址。
- 地點 ID 的地址。
您可以控制結果顯示的位置,並將結果限制在特定區域、縣或郵遞區號。
Geocoding API 的運作方式
Geocoding API 可執行地理編碼和反向地理編碼:
- 地理編碼:將地址 (例如「1600 Amphitheatre Parkway, Mountain View, CA」) 轉換為緯度和經度座標或地點 ID。您可以使用這些座標在地圖上放置標記,或是將地圖置中或重新定位在檢視框內。
- 反向地理編碼:將經緯度座標或地點 ID 轉換為人類可讀的地址。您可以將地址用於各種情況,包括送貨或取貨。
以下示範內容會透過 Maps JavaScript API 使用地理編碼服務,展示 Geocoding API 的運作方式。在另一個分頁中開啟地圖,即可查看更多選項和詳細資料。
資源
下表摘要列出可透過 Geocoding API 取得的資源,以及每個端點傳回的資料。
如何使用 Geocoding API
1 |
進行設定。 |
請先設定 Google Cloud 專案,然後完成後續設定說明。 |
2 |
嘗試地理編碼要求 |
取得 API 金鑰後,您就可以直接透過 curl 或瀏覽器測試 Geocoding API。您必須為地址或元件查詢提供正確的查詢參數。詳情請參閱「地理編碼參數」。 |
3 |
嘗試反向地理編碼要求 |
請提供經緯度座標和 API 金鑰,以便取得該位置最接近且人類可讀的地址的地址元件。詳情請參閱「反向地理編碼要求」一文。 |
4 |
瞭解回應的基本概念 |
Geocoding API 中的所有端點都會以 JSON 或 XML 格式傳回相同的資料。如要瞭解資料、狀態碼和錯誤訊息,請參閱「Geocoding 回應」。 |
5 |
將地理編碼資料納入您自己的應用程式! |
您可以使用地理編碼資料,從地圖標記取得地址,或是根據已知地址在地圖上提供標記。 |
可用的用戶端程式庫
透過下列任一用戶端程式庫,以您選擇的語言呼叫此 API:
Google 地圖服務適用的 Java、Python、Go 和 Node.js 用戶端都是社群支援的用戶端程式庫,並依據 Apache 2.0 授權的條款提供開放原始碼。您可以從 GitHub 下載這些用戶端或相關貢獻項目,並查看安裝操作說明和程式碼範例。
後續步驟
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-31 (世界標準時間)。
[null,null,["上次更新時間:2025-08-31 (世界標準時間)。"],[[["\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)."]]