시작하기
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지에서는 장소 클래스를 사용할 수 있도록 API 키를 가져오고, 필요한 API를 사용 설정하고, 장소 라이브러리를 로드하는 방법을 보여줍니다.
API 키 가져오기 및 필수 API 사용 설정
장소 클래스를 사용하기 전에 다음을 실행해야 합니다.
- 결제 계정으로 Cloud 프로젝트를 만듭니다.
- API 키를 가져옵니다.
- 다음 API를 사용 설정합니다.
- Maps JavaScript API
- Places API
- Places API (신규) (텍스트 검색 (신규) 및 장소 자동 완성을 사용하기 위해 필요함)
자세한 내용은 Google Cloud 프로젝트 설정을 참고하세요.
API 키 가져오기
Places API(신규) 사용 설정
장소 라이브러리 로드
장소 라이브러리를 로드하려면 다음 스니펫과 같이 애플리케이션 코드에 인라인 부트스트랩 로더를 추가하여 Maps JavaScript API를 먼저 로드하세요.
<script>
(g=>{var h,a,k,p="The Google Maps JavaScript API",c="google",l="importLibrary",q="__ib__",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=>h||(h=new Promise(async(f,n)=>{await (a=m.createElement("script"));e.set("libraries",[...r]+"");for(k in g)e.set(k.replace(/[A-Z]/g,t=>"_"+t[0].toLowerCase()),g[k]);e.set("callback",c+".maps."+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=>h=n(Error(p+" could not load."));a.nonce=m.querySelector("script[nonce]")?.nonce||"";m.head.append(a)}));d[l]?console.warn(p+" only loads once. Ignoring:",g):d[l]=(f,...n)=>r.add(f)&&u().then(()=>d[l](f,...n))})({
key: "YOUR_API_KEY",
v: "weekly",
// Use the 'v' parameter to indicate the version to use (weekly, beta, alpha, etc.).
// Add other bootstrap parameters as needed, using camel case.
});
</script>
그런 다음 아래와 같이 await
연산자를 사용하여 async
함수 내에서 importLibrary()
를 호출합니다.
const {Place} = await google.maps.importLibrary("places");
함수는 필요한 클래스의 변수를 선언하지 않고도 라이브러리를 로드할 수 있습니다.
async function initMap() {
google.maps.importLibrary("places");
...
}
initMap();
또는 다음과 같이 HTML에 라이브러리를 직접 로드할 수도 있습니다.
<script>
google.maps.importLibrary("places");
</script>
라이브러리 로드에 관한 자세한 내용은 Maps JavaScript API 로드를 참고하세요.
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-10(UTC)
[null,null,["최종 업데이트: 2025-08-10(UTC)"],[[["\u003cp\u003eThis guide explains how to prepare your application to work with the Google Maps Places API's Place class.\u003c/p\u003e\n"],["\u003cp\u003eYou'll need to set up a Cloud project, obtain an API key, and enable necessary APIs including Maps JavaScript API, Places API, and Places API (New).\u003c/p\u003e\n"],["\u003cp\u003eThe Places Library is loaded by including the Maps JavaScript API bootstrap loader and then calling \u003ccode\u003eimportLibrary("places")\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eOnce set up, you can utilize the Place class for searching places, retrieving details, and using Place Autocomplete.\u003c/p\u003e\n"]]],["To use the Place class, you must first create a Cloud project with billing, obtain an API key, and enable the Maps JavaScript API, Places API, and Places API (New). Then, load the Places Library by including the Maps JavaScript API bootstrap loader in your code, and utilizing the `importLibrary()` function within an `async` context. This allows for the use of the \"places\" library, and subsequent place related tasks.\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\nThis page shows you how to get an API key, enable the required APIs, and load the Places Library,\nso that you can work with the Place class.\n\nGet an API key and enable the required APIs\n\nBefore using the Place class, you need to:\n\n- Create a Cloud project with a billing account.\n- Get an API key.\n- Enable the following APIs: \n - Maps JavaScript API\n - Places API\n - Places API (New) (required to use Text Search (New) and Place Autocomplete)\n\nTo learn more, see [Set up your Google Cloud project](/maps/documentation/javascript/cloud-setup).\n[Get an API key](/maps/documentation/javascript/get-api-key)\n\n\n[Enable Places API (New)](https://console.cloud.google.com/apis/library/places.googleapis.com)\n\nLoad the Places Library\n\nTo load the Places Library, first load the Maps JavaScript API, by adding the\ninline bootstrap loader to your application code, as shown in the following snippet: \n\n```javascript\n\u003cscript\u003e\n (g=\u003e{var h,a,k,p=\"The Google Maps JavaScript API\",c=\"google\",l=\"importLibrary\",q=\"__ib__\",m=document,b=window;b=b[c]||(b[c]={});var d=b.maps||(b.maps={}),r=new Set,e=new URLSearchParams,u=()=\u003eh||(h=new Promise(async(f,n)=\u003e{await (a=m.createElement(\"script\"));e.set(\"libraries\",[...r]+\"\");for(k in g)e.set(k.replace(/[A-Z]/g,t=\u003e\"_\"+t[0].toLowerCase()),g[k]);e.set(\"callback\",c+\".maps.\"+q);a.src=`https://maps.${c}apis.com/maps/api/js?`+e;d[q]=f;a.onerror=()=\u003eh=n(Error(p+\" could not load.\"));a.nonce=m.querySelector(\"script[nonce]\")?.nonce||\"\";m.head.append(a)}));d[l]?console.warn(p+\" only loads once. Ignoring:\",g):d[l]=(f,...n)=\u003er.add(f)&&u().then(()=\u003ed[l](f,...n))})({\n key: \"YOUR_API_KEY\",\n v: \"weekly\",\n // Use the 'v' parameter to indicate the /maps/documentation/javascript/versions to use (weekly, beta, alpha, etc.).\n // Add other /maps/documentation/javascript/load-maps-js-api#required_parameters as needed, using camel case.\n });\n\u003c/script\u003e\n```\n\nNext, use the `await` operator to call `importLibrary()`\nfrom within an `async` function, as shown here: \n\n```javascript\n const {Place} = await google.maps.importLibrary(\"places\");\n \n```\n\nYour function can also load libraries without declaring a variable\nfor the needed classes: \n\n```javascript\n async function initMap() {\n google.maps.importLibrary(\"places\");\n ...\n }\n\n initMap();\n \n```\n\nAlternatively, you can load the libraries directly in HTML as shown here: \n\n```javascript\n \u003cscript\u003e\n google.maps.importLibrary(\"places\");\n \u003c/script\u003e\n \n```\n\n\nFor more information about loading libraries, see\n[Load the Maps JavaScript API](/maps/documentation/javascript/load-maps-js-api).\n\nNext steps\n\n- [Search for places](/maps/documentation/javascript/place-search)\n- [Get place details](/maps/documentation/javascript/place-details)\n- [Use Place Autocomplete](/maps/documentation/javascript/place-autocomplete-new)"]]