| description |
|---|
Add a google map to your website. |
{% hint style="success" %} The Map component is available as a free download via the Element Store, it requires a free Google Maps API key to function. {% endhint %}
To use the Maps component in Elements you need a Maps API key from Google. It only takes a few minutes to set up. The quickest way to get setup is to watch the video and follow the instructions below.
{% embed url="https://youtu.be/hsNlz7-abd0?si=GdUJB8TqHNtGwXkm" %}
Visit the Google Cloud Console and sign in. If you have not used Google Cloud before, it will prompt you to create a new project.
- Open the project selector at the top of the page
- Click New Project
- Give it a name, then create it
- With your new project selected, open the left sidebar
- Go to APIs and Services
- Click Enable APIs and Services
- Search for Maps JavaScript API & Geocoding API
- Open them and click Enable for both
This screenshot shows the expected appearance after enabling both the Maps JavaScript API and the Geocoding API.
- In APIs and Services, go to Credentials
- Click Create Credentials
- Choose API key
- Copy the key that appears
For security, set restrictions so the key can only be used from your website.
- In the Credentials list, click your new key
- Under Application Restrictions select Websites
- Add the domains where your site will run
- Save your changes
Open the Google Map component in Elements and paste the key into the API Key field. Once added, your map will load correctly during preview and when published.
When working locally, you need to add referrers so your Google Maps API key works in both Elements preview and on your published site.
Add your live domain with two referrers:
https://www.mydomain.com/
https://www.mydomain.com/*
To support local preview, first open the Elements Advanced settings and set a fixed preview port so it stays consistent.
Add that URL as another two referrers in the Google console. For example:
http://127.0.0.1:61109
http://127.0.0.1:61109/*
Below are example settings for the API Key:
This screenshot shows the API Key's settings.


