API Key
Last updated
Last updated
There is one final step that needs to be added to the HTML page: an API key for GoogleMaps. This module will walk you through getting that key.
GoogleMaps is an API provided by Google. There are many different APIs that Google offers, so if you're interested, feel free to play around with some of those later.
If you haven't already, log into your Google Firebase account and create a project. The name doesn't matter; we're just using this project for the API Keys.
Go to the
Select your project from the list, then click `+ENABLE APIS AND SERVICES".
Search for Maps, then click on Google Maps Javascript API.
Click Enable.
In the side menu, click credentials, then click Create Credentials and select API Key.
Copy your API key and paste it in the apikeys.txt
file.
Add the following lines to the end of the body of the googlemaps.html
file. Replace INSERT-YOUR-API-KEY-HERE
with your key:
IMPORTANT MAKE SURE YOU ADDED THE apikeys.txt
FILE TO YOUR .gitignore
! If you don't, all your API keys will be published to GitHub for anyone to use. Anytime you are using something for authentication or encryption purposes, make sure it's not accidentally pushed to GitHub.
Commit your work here as "GoogleMaps - API Key added".
This adds both the API Key and your googlemaps.js file to the html
file. Next, we'll work on the JavaScript file.