npm install @googlemaps/js-api-loader
Alternatively, the following script can be added to the HTML document.
The full sample code is below.
Git and Node.js are required to run this sample locally. Follow these instructions to install Node.js and NPM. The following commands clone, install dependencies and start the sample application.
git clone -b sample-programmatic-load-button https://github.com/googlemaps/js-samples.git
Other samples can be tried by switching to any branch beginning with
git checkout sample-SAMPLE_NAME