The Address component looks up addresses with Google Maps as the user types, and saves the full, standardized address. It needs a Google Maps API key and a change to your security headers.
If you don't need address lookup, use separate Text Fields for street, city, state and postal code. They're simpler, need no outside service, and map more easily to PDFs and other systems.
Before you begin
-
A Google Cloud project with the Geocoding API enabled, and an API key for it. Restrict the key to the Geocoding API and to your GlobalForms address.
-
Google charges for geocoding requests beyond its free allowance. Check Google's current pricing.
-
Users' browsers must be able to reach
maps.googleapis.com.
Set up the component
-
Add the
maps.googleapis.comsite to theconnect-srcpart of the Content-Security-Policy header, for exampleconnect-src 'self' https://maps.googleapis.com. See Security Headers. Without this, the lookup is blocked. -
Drag an Address component onto the form.
-
On the Display tab, enter the Google Maps API Key.
-
Optionally set Region Bias to a two-letter country code, such as
us, to prefer results in that country. -
Save and test the form.
Settings
|
Setting (Display tab) |
What it does |
|---|---|
|
Google Maps API Key |
Your key for the Google Geocoding API |
|
Region Bias |
Prefers results in one country |
|
Allow Multiple Addresses |
Lets users enter more than one address |
What is saved
The submission stores the Google result for the chosen address. The submissions list shows its formatted address, for example 1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA. In scripts, use data.address.formatted_address; the individual parts are in data.address.address_components.
The API key is saved in the form definition, which anyone who can open the form can read. Restrict the key in Google Cloud so it can only be used for geocoding from your GlobalForms address.