Get Started (original) (raw)

This page shows you how to get an API key, enable the required APIs, and load the Places Library, so that you can work with the Place class.

Get an API key and enable the required APIs

Before using the Place class, you need to:

To learn more, see Set up your Google Cloud project.

Get an API key

Enable Places API (New)

Load the Places Library

To load the Places Library, first load the Maps JavaScript API, by adding the inline bootstrap loader to your application code, as shown in the following snippet:

Next, use the await operator to call importLibrary() from within an async function, as shown here:

const {Place} = await google.maps.importLibrary("places");

Your function can also load libraries without declaring a variable for the needed classes:

async function initMap() { google.maps.importLibrary("places"); ... }

initMap();

Alternatively, you can load the libraries directly in HTML as shown here:

For more information about loading libraries, seeLoad the Maps JavaScript API.

Next steps