데이터 기반 경계 스타일 지정과 함께 Places 서비스 및 Geocoding API 사용
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
Android용 Maps SDK에서 Places 서비스와 Geocoding API를 사용하여 지역을 검색하고 장소에 대한 자세한 정보를 얻을 수 있습니다. Places 서비스 및 Geocoding API는 장소 ID를 가져오기 위한 강력하고 안정적인 대안입니다. 이미 장소 ID를 사용하고 있다면 데이터 기반 경계 스타일 지정과 함께 ID를 재사용할 수 있습니다.
다음과 같은 방법으로 Places 서비스 및 Geocoding을 Android용 Maps SDK 앱에 추가합니다.
Places 서비스 사용
텍스트 검색 (신규)을 사용하여 장소 ID 찾기
Places API의 텍스트 검색 (신규) REST API를 사용하여 필드 마스크에 places.id
을 지정하여 지역 데이터를 포함하는 장소 ID를 가져올 수 있습니다. 장소 ID 요청만을 위해 Text Search (New)를 사용하는 데에는 비용이 청구되지 않습니다. 자세히 알아보기
예를 들어 캘리포니아주 트리니다드의 장소 ID를 가져오려면 다음 API 호출을 실행하면 됩니다.
curl -X POST -d '{
"textQuery" : "Trinidad, CA"
}' \
-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: API_KEY' \
-H 'X-Goog-FieldMask: places.id' \
'https://places.googleapis.com/v1/places:searchText'
Place Autocomplete를 사용하여 지역 찾기
Android용 Places SDK의 Place Autocomplete 서비스는 사용자가 지역을 검색할 수 있는 편리한 방법을 제공합니다. 지역만 반환하도록 Place Autocomplete 서비스를 구성하려면 AutocompleteSupportFragment.setTypesFilter(List)
를 사용하여 유형 필터를 PlaceTypes.REGIONS
로 설정하세요.
지역의 장소 세부정보 가져오기
Android용 Places SDK의 장소 세부정보 서비스는 지역의 데이터를 반환하며 이는 매우 유용할 수 있습니다. 예를 들어 다음과 같은 작업을 할 수 있습니다.
- 장소 이름을 기반으로 경계 장소 ID 검색
- 경계를 확대/축소하기 위해 표시 영역 가져오기
- 경계의 지형지물 유형(예:
locality
) 가져오기
- 미국 내 지역의 '장소 이름, 주, 국가' 형식으로 지정된 주소 가져오기 (예: 'Ottumwa, IA, USA')
- 사진 등 기타 유용한 데이터 가져오기
Geocoding API 사용
Geocoding API를 사용하면 주소를 위도 및 경도 좌표와 장소 ID로 변환하거나 위도 및 경도 좌표 또는 장소 ID를 주소로 변환할 수 있습니다. 다음은 데이터 기반 경계 스타일 지정과 잘 어울리는 예입니다.
- 지오코딩을 사용하여 지역의 표시 영역을 가져옵니다.
- 지오코딩 호출에 구성요소 필터링을 적용하여 행정 구역 1~4, 지역 또는 우편번호에 대한 장소 ID를 가져옵니다.
- 역 지오코딩을 사용하여 위도 및 경도 좌표로 장소 ID를 찾거나 특정 위치의 모든 구성요소에 대한 장소 ID를 반환합니다.
다음 예에서는 주소 (URL로 이스케이프됨)를 사용하여 Geocoding API에 요청합니다.
https://maps.googleapis.com/maps/api/geocode/json?address=1600%20Amphitheatre%20Pkwy%20Mountain%20View%20CA&key=YOUR_API_KEY
역 지오코딩을 사용하여 장소 ID를 찾을 수 있습니다. 다음 지오코딩 서비스 함수는 지정된 위도 및 경도 좌표에 있는 모든 주소 구성요소의 장소 ID를 반환합니다.
https://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&key=YOUR_API_KEY
역 지오코딩을 구성요소 필터링과 함께 사용하여 지정된 위치에서 다음 유형 중 하나 이상의 주소 구성요소를 가져오는 방법은 다음과 같습니다.
administrativeArea
country
locality
postalCode
다음 함수 예는 지오코딩 서비스를 사용하여 locality
유형의 경우에만 지정된 위치의 모든 주소 구성요소를 가져오는 역 지오코딩의 구성요소 제한을 추가하는 방법을 보여줍니다.
https://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&result_type=locality&key=YOUR_API_KEY
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-31(UTC)
[null,null,["최종 업데이트: 2025-08-31(UTC)"],[[["\u003cp\u003eYou can use the Places Service and Geocoding API with the Maps SDK for Android to find place IDs for regions and get more information about them for data-driven styling.\u003c/p\u003e\n"],["\u003cp\u003eThe Places SDK for Android, Places API, and Geocoding API can be used to search for regions and retrieve their details, including place IDs, viewport, feature type, and formatted address.\u003c/p\u003e\n"],["\u003cp\u003eText Search (New) in the Places API, Places Autocomplete in the Places SDK for Android, and the Geocoding API are methods for obtaining place IDs.\u003c/p\u003e\n"],["\u003cp\u003eWhen using these services, be aware that the Places SDK for Android, Places API, and Geocoding API require enabling and are billed separately from the Maps SDK for Android.\u003c/p\u003e\n"]]],[],null,["# Use the Places Service and Geocoding API with data-driven styling for boundaries\n\nSelect platform: [Android](/maps/documentation/android-sdk/dds-boundaries/dds-use-maps-places-apis \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/dds-boundaries/dds-use-maps-places-apis \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/dds-boundaries/dds-use-maps-places-apis \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nYou can use the Places Service and the\nGeocoding API with the Maps SDK for Android to search for regions, and\nget more information about places. The Places Service\nand Geocoding API are powerful and stable alternatives for obtaining\nplace IDs. If you're already using place IDs, you can reuse those IDs with\ndata-driven styling for boundaries.\n\nAdd the Places Service and Geocoding to your\nMaps SDK for Android apps in the following ways:\n\n- [Places SDK for Android](/maps/documentation/places/android-sdk) is an Android library containing methods to returns information about places.\n- [Places API](/maps/documentation/places/web-service) returns information about places using HTTP requests.\n- [Geocoder class](https://developer.android.com/reference/android/location/Geocoder) can geocode and reverse geocode dynamically from user input.\n- [Geocoding API](/maps/documentation/geocoding) lets you geocode static, known addresses.\n\n| **Note:** The [Places SDK for Android](/maps/documentation/places/android-sdk), [Places API](/maps/documentation/places/web-service), and [Geocoding API](/maps/documentation/geocoding/cloud-setup) must be enabled, and are billed separately from the Maps SDK for Android.\n\nUse the Places Service\n----------------------\n\n### Use Text Search (New) to find a place ID\n\nYou can use [Text Search (New)](/maps/documentation/places/web-service/text-search)\nREST API in the Places API to get a place ID that includes region\ndata by specifying `places.id` in the field mask. Usage of the\nText Search (New) to request place IDs only incurs\nno charge. [Learn more](/maps/documentation/places/web-service/preview-billing).\n\nFor example, to get the place ID for Trinidad, CA you can make the following\nAPI call: \n\n```\ncurl -X POST -d '{\n \"textQuery\" : \"Trinidad, CA\"\n}' \\\n-H 'Content-Type: application/json' -H 'X-Goog-Api-Key: \u003cvar translate=\"no\"\u003eAPI_KEY\u003c/var\u003e' \\\n-H 'X-Goog-FieldMask: places.id' \\\n'https://places.googleapis.com/v1/places:searchText'\n```\n\n### Use Places Autocomplete to find regions\n\nThe [Places Autocomplete](/maps/documentation/places/android-sdk/autocomplete)\nservice in the Places SDK for Android provides a convenient way to let\nyour users search for regions. To configure the Places Autocomplete service to\nreturn only regions, use\n[`AutocompleteSupportFragment.setTypesFilter(List)`](/maps/documentation/places/android-sdk/reference/com/google/android/libraries/places/widget/AutocompleteSupportFragment#setTypesFilter(java.util.List%3Cjava.lang.String%3E))\nto set the type filter to `PlaceTypes.REGIONS`.\n\n### Get place details for a region\n\nThe [Place Details](/maps/documentation/places/android-sdk/place-details)\nservice in the Places SDK for Android returns data for a region can be\nquite useful. For example, you can:\n\n- Search for boundary place IDs based on place names.\n- Get the viewport for zooming to a boundary.\n- Get the feature type for the boundary (for example `locality`).\n- Get the formatted address, which resolves to \"Place Name, State, Country\" in the United States region (for example, \"Ottumwa, IA, USA\").\n- Get other useful data such as photos.\n\nUse the Geocoding API\n---------------------\n\nThe [Geocoding API](/maps/documentation/geocoding) lets you convert\nan address into latitude and longitude coordinates and a Place ID, or converts\nlatitude and longitude coordinates or a Place ID into an address. The following\nuses combine well with data-driven styling for boundaries:\n\n- Use Geocoding to get the viewport for a region.\n- Apply component filtering to your Geocoding call to get the place IDs for administrative areas 1-4, locality, or postal code.\n- Use reverse geocoding to find place IDs by latitude and longitude coordinates, or even return place IDs for all components in a particular location.\n\nThe following example uses an address (url-escaped) to make a request to the\nGeocoding API: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?address=1600%20Amphitheatre%20Pkwy%20Mountain%20View%20CA&key=YOUR_API_KEY\n```\n\nYou can use [reverse geocoding](/maps/documentation/geocoding/requests-reverse-geocoding)\nto find place IDs. The following example Geocoding\nservice function returns the place IDs for all address components at the\nspecified latitude and longitude coordinates: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&key=YOUR_API_KEY\n```\n\nUse reverse geocoding with component filtering to get the address component\nfor one or more of the following types at the specified location:\n\n- `administrativeArea`\n- `country`\n- `locality`\n- `postalCode`\n\nThe next example function shows using the Geocoding service, adding component\nrestrictions with reverse geocoding to get all of the address components at the\nspecified location for only the `locality` type: \n\n```html\nhttps://maps.googleapis.com/maps/api/geocode/json?latlng=41.864182,-87.676930&result_type=locality&key=YOUR_API_KEY\n```"]]