🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Mapbox and Geoapify Address Autocomplete Premium Add-on Setup Guide

Updated 10 min read Gravity Forms Fields & Inputs
On this page
  1. Video walkthrough
  2. What you need
  3. Install and set the provider
  4. Geoapify
  5. Mapbox
  6. LocationIQ
  7. Switch it on for a field
  8. Address fields
  9. Single line text fields
  10. Search defaults
  11. Keep the billing low
  12. Hide the key (server-side proxy)
  13. The map preview
  14. Accessibility and languages
  15. Developers
  16. Privacy and security
  17. Troubleshooting
  18. Questions
  19. Do I need a Google account?
  20. Can I use more than one provider on one site?
  21. Can I use it on a form with several address fields?
  22. Does it work in Ajax forms and on multi page forms?
  23. What happens if I switch the provider off or deactivate the add-on?

Video walkthrough

Gravity Forms Mapbox & Geoapify Address Autocomplete Setup Guide (WordPress Side)
Video setup guide: Gravity Forms Mapbox & Geoapify Address Autocomplete Watch on YouTube

The Gravity Forms Mapbox and Geoapify Address Autocomplete Premium Add-on suggests addresses while a visitor types in a Gravity Forms Address field or in a Single Line Text field, and fills the street, city, state, postcode and country with one click. It uses Mapbox, Geoapify or LocationIQ, so it works without a Google account. It can also save the latitude and longitude with the entry and show a small map with a pin that the visitor can drag.

You choose one provider for the whole site, create a key at that provider, and paste it in the add-on settings. You can send the requests straight from the visitor’s browser, with a key that you restrict to your site address at the provider, or you can switch on Hide the key: then the browser asks your own site and your server asks the provider, so the key never leaves the server.

What you need

  • WordPress 6.5 or newer and PHP 7.4 or newer.
  • Gravity Forms 2.9 or newer. The add-on is tested with Gravity Forms 3.1.2 on PHP 8.3 and Gravity Forms 2.9.8 on PHP 7.4.
  • An active license key for this add-on.
  • A key from one provider: a Geoapify API key, a Mapbox public access token, or a LocationIQ access token. All three offer a free plan you can sign up for yourself.

If Gravity Forms is missing or older than 2.9, the add-on shows a notice in the WordPress admin and does nothing else. Without a valid license, or without a key, the forms work exactly as before.

Install and set the provider

  1. Install and activate the add-on like any plugin, after Gravity Forms.
  2. Open Forms → Settings → Address Autocomplete and enter your license key.
  3. Choose the address provider and paste its key or token.
  4. Press Save Settings.

Geoapify

Create a project at Geoapify, copy its API key and, in the project settings, add your site address to the allowed origins. Geoapify Autocomplete returns the street, house number, city, state, postcode and country with a latitude and longitude. The add-on sends the text, the language, the country filter, the type and a limit; nothing else.

Mapbox

Create a public access token (it starts with pk.) and restrict it to your site address in the Mapbox account. You can use two services. Search Box is the default: the add-on asks for suggestions while the visitor types and asks once for the details of the address that was chosen, with the same session token, so Mapbox bills one session per address and not one request per key stroke. Geocoding v6 returns the full address in each answer, but every pause in typing is a billed request. A secret token (sk.) is never printed into a page: it works only when Hide the key is on.

Mapbox allows the coordinates of Geocoding v6 answers to be stored only with permanent results. If you save the latitude and longitude with entries and use Geocoding v6, switch on Mapbox permanent results; the add-on then adds the permanent parameter to those requests. Search Box and the map are not affected.

LocationIQ

Create an access token at LocationIQ and add your site address to its allowed referrers. The add-on uses the autocomplete service with the city normalised, duplicates removed and state codes included.

Switch it on for a field

Open a form in the editor, click an Address field or a Single Line Text field and open the Advanced tab. The panel Address autocomplete has these settings:

The address autocomplete settings of one field in the Gravity Forms form editor: switch on, countries, what to suggest, latitude and longitude fields and the map
The settings of one field in the form editor.
  • Suggest addresses while typing: the on and off switch of the field.
  • Only these countries: two letter codes separated by commas, for example us,ca. Empty uses the list from the add-on settings. Up to ten countries.
  • What to suggest: street addresses, postcodes or cities. A field that asks for cities gets the city name; a postcode field gets the postcode.
  • Save the latitude in and Save the longitude in: choose a hidden, text, drop down or number field of the same form. The values are saved with the entry like any other answer.
  • Show a map with a draggable pin: the map preview described below.

Address fields

On an Address field the suggestions come while the visitor types in the Street Address line. A choice fills the street, the city, the state or region, the postcode and the country. Drop downs are matched by name, so the country list and the list of US states or Canadian provinces are set correctly, with or without accents, and a state that is not in the list is left empty instead of being guessed. The second address line is never touched.

A Gravity Forms address field with the first letters of a street typed and a list of two street suggestions with the city, postcode and country under each
Suggestions appear while the visitor types, with the city, postcode and country under each street.

Single line text fields

A text field can be the one line where a visitor types the whole address. The field itself receives the street and number (or the whole address on one line, if you tick that box), and the panel lets you pick other fields of the same form for the street and number, city, state or region, postcode and country. A country drop down is matched by its label or its value. House numbers follow the custom of the country: 10 Downing Street in the United Kingdom and the United States, Lessingstrasse 5 in Germany.

Search defaults

  • Only these countries: used by every field that has no list of its own.
  • Language of the suggestions: for example en or de. Empty uses the language of the site.
  • What to suggest: the default type.
  • Favour places near the visitor: No; By the visitor’s IP address, where the provider decides; or By the browser location. The browser asks the visitor for permission when the field is first used, and the position is rounded to about 10 metres and kept only in the page. If the visitor says no, the search works as if the option were off.
  • Characters before the first search: 3 by default.
  • Wait after typing: 300 milliseconds by default. A search is sent only after the visitor pauses, and an older search is cancelled when a newer one starts, so a slow answer can never replace a newer one.
  • Suggestions shown: 1 to 10.

Keep the billing low

  • The wait after typing and the minimum characters cut most requests.
  • Mapbox Search Box uses one session token for the suggestions and the final choice, and starts a new one after each choice, after 45 searches or after three minutes of silence, as Mapbox asks.
  • For Geoapify and LocationIQ, the same text typed again on the same page is answered from memory. Mapbox results are not reused, because its terms do not allow it.
  • Filling in the street after a choice does not start another search.
  • A country list makes the suggestions shorter and better, so visitors find their address after fewer letters.

Hide the key (server-side proxy)

With Hide the key switched on, the page contains no key. The visitor’s browser sends the search to your site, and your server adds the key and asks the provider. This is the choice for a Mapbox secret token, for a key that cannot be restricted by address, and for sites that want every request under their own control.

  • Only fields that have the autocomplete switched on can be asked for, only the endpoints of the chosen provider, and only the parameters of the table in the add-on. A key or a parameter sent by a visitor is ignored.
  • Every visitor has a limit of requests per minute, counted per IP address (default 60, 0 turns it off). Over the limit the site answers with 429 and a Retry-After header, and the provider is not asked. Map tiles have a limit that is 15 times higher.
  • Without a valid license, or when the form is not active, the proxy refuses.
  • If the provider is down, the visitor sees a short message and can type the address by hand.

The map preview

When Show a map with a draggable pin is on, a map appears under the field after the visitor chooses an address, or when the form is opened with coordinates already filled in. The map is drawn with MapLibre GL, which is included in the add-on, so there is no script from another site. The tiles come from the provider you chose (Mapbox raster tiles, Geoapify OSM Bright or LocationIQ streets), with the attribution the provider asks for. You can give your own https tile address in the settings if you are allowed to use it, and with Hide the key the tiles are fetched by your server.

A Gravity Forms address field filled in, with a map under it that shows a draggable pin at the chosen address and the map attribution
The optional map shows a pin that the visitor can drag; the address is looked up again.
  • Drag the pin, or click the map: the latitude and longitude fields change and the nearest address is looked up (reverse geocoding) and filled in. The pin stays where the visitor put it.
  • Keyboard: focus the pin with the Tab key and use the arrow keys. Several key presses are collected into one lookup.
  • If no address is found at the spot, the coordinates are kept and a message says so.

Accessibility and languages

The field follows the ARIA combobox pattern: the input has the role combobox with aria-expanded, aria-controls and aria-activedescendant, the list has the role listbox and each suggestion is an option. The Down and Up arrows move through the suggestions and wrap around, Enter chooses, Escape closes the list and keeps the text, and Tab closes it and moves on. Pressing Enter with the list open and no suggestion marked closes the list instead of sending a half typed address. A polite live region tells screen reader users how many suggestions there are, that none were found, that the provider is not available, and which address was filled in. Right-to-left languages are supported: the list and its marker use logical sides, and it lines up with the field in a right-to-left page. The texts can be translated with the text domain of the add-on.

Developers

  • Everything is saved as normal Gravity Forms values, so entries, exports, notifications, merge tags and other add-ons see the street, city, state, postcode, country, latitude and longitude as usual.
  • The script triggers the event gfgeoapi:filled on the input, with the place in the event detail (street, city, state, postcode, country, latitude, longitude), after each fill. The standard input and change events are fired on every field that is filled, so conditional logic and calculations react.
  • The field settings are stored in the form as field properties (gfgeoapiEnable, gfgeoapiCountry, gfgeoapiTypes, gfgeoapiMap, gfgeoapiFull, gfgeoapiLat, gfgeoapiLng, gfgeoapiToStreet and so on), so forms can be exported and imported with their settings.

Privacy and security

Without Hide the key, the visitor’s browser sends the typed text, the language, the country filter and, if you chose the browser location, the rounded position to the provider you chose, and so the provider sees the visitor’s IP address. With the key hidden, the provider sees your server instead. Add the provider to your privacy policy either way. The add-on stores nothing about visitors: the only data kept is what the visitor submits in the form. Secret Mapbox tokens are never printed into a page. The proxy checks the form, the field, the endpoint and every parameter, and limits the requests of each visitor. Coordinates are saved only when you choose fields for them.

Troubleshooting

  • No suggestions: check the license, that a key is saved for the provider you chose, that the field has the switch on, and that the key allows your site address. A message under the field says when the provider answers with an error.
  • A Mapbox secret token does nothing: it needs Hide the key.
  • The country is not selected: the drop down must contain the country by name; a country that the list does not have is left empty.
  • The map is empty: the tiles are blocked by the key restrictions of the provider. Check the allowed addresses.
  • A page cache: the add-on prints no per visitor data, so pages can be cached.

Questions

Do I need a Google account?

No. This add-on uses Mapbox, Geoapify or LocationIQ. If you prefer Google, our Google Address Autocomplete add-on does that job; the two are separate products.

Can I use more than one provider on one site?

One provider serves the whole site. Change it in the settings at any time; the forms need no change.

Can I use it on a form with several address fields?

Yes. Each field has its own switch, countries and map, and each fills only its own inputs.

Does it work in Ajax forms and on multi page forms?

Yes. The fields start again each time the form is drawn.

What happens if I switch the provider off or deactivate the add-on?

The forms become plain forms again and keep everything the visitors typed. Saved entries are not changed.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr