To use the location field and let form respondents interact with Google Maps, your organization needs an active Google Maps API key. Here's how to set one up.
Before you begin, you need a Google Account. You might already one if your organization uses Google Analytics. If you don't, it's easy to set up a Google Account.
Once you have a Google Account, go to the Google Maps Platform and sign in with your details.
If you need help using Google Maps Platform, visit Google’s Cloud Platform Console Help Center.
1. Get started with Google Maps Platform
- On the Google Maps Platform homepage, select Get Started.
- Check the boxes for Maps, Routes, and Places, then click Continue.
- Select a project, then click Next.
2. Link a billing account with your project
Google will ask you to enable billing with a credit card for all projects. If you choose not to add a billing account, your maps will be lower quality and water marked. They may also stop working if your API calls exceed the complimentary value of $200 per month. See Google’s guide for more information.
After you click Next, you’ll be directed to set up a billing account straight away.
If you’re an existing user of Google Maps Platform and you need to link a billing account, use the Google Maps Platform Transition Tool.
You will only be charged if your API calls exceed the complimentary value of $200 per month. If you don’t exceed this value, you’ll still be able to use Google Maps Platform for free.
3. Set up an API key for your project
Google requires you to have a valid API key for all projects. If you don’t set up an API key and a billing account, your maps will stop working when your API calls exceed the complimentary value of $200 per month. See Google’s guide for more information.
- Once you’ve linked a billing account, enable your APIs. You’ll get an API key straight away. Copy the API key and paste it into Notepad for later.
- Go to the API Console Credentials area to secure your credentials.
- Restrict your API key to allow OpenForms to use it. To do this, either click Secure Credentials at the top of the page or go to the Credentials area and edit your key.
- Under Key restrictions > Application restrictions, select HTTP referrers (web sites).
- Choose Add an Item and enter *.openforms.com/* as a Referrer.
Confirm your submission by clicking Done.
- Save your changes to start using your API key.
When does OpenForms contact Google Maps
OpenForms contacts the following Google Maps APIs when respondents use the location field:
- Google Places API Web Service
This API is called when respondents enter text in a form's location field and pause for at least half a second to display predictive results.
- Google Maps Geocoding API
This API is called when:
- Respondents click on a map in the location field to mark a location.
- Respondents select a predictive text option from the location field.
- Respondents select the Use my location option in the location field.
This API is called when a respondent opens a form, or loads a saved form.
- It does not get called when a respondent navigates between form sections.
- It does get called when a location field is shown as a result of a display logic scenario.
If you are concerned about exceeding your Google Maps API call quota and incurring a cost, consider not using display logic for location fields.