🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!
Guides & Tutorials October 20, 2026

OpenStreetMap Map Field for Gravity Forms: Pin Picker With No API Key

GravityExtra
OpenStreetMap Map Field for Gravity Forms: Pin Picker With No API Key

Where is the problem, where should the bench go, where should we deliver it? Some questions are answered much better with a pin on a map than with a typed address, and people rarely type an address correctly when they are standing in a park. Most guides for this reach for a Google map and an API key. You do not need one. OpenStreetMap is a free map of the world and Leaflet is a small, well-known library that draws it. This post shows how to add a map picker to a Gravity Forms form that saves the coordinates and the address, and what you must know about the usage rules of the free map services before you go live. It uses the Gravity Forms Map Picker add-on.

A Report a problem form on the site: the Problem location field shows a search box, the Use my location and Clear pin buttons, an OpenStreetMap map with a blue pin, and underneath the latitude, longitude and address boxes filled with the position of the pin and the address that was found
The map field on a form: search box, location button, a draggable pin, and the latitude, longitude and address that will be saved.

When a Map Field Beats an Address Field

An address field is the right tool for a delivery address. A map is better when the place has no address or the visitor does not know it: a pothole, a broken light, a spot in a field for an event, a trailhead, a lost pet, a meeting point on a campus. It is also better when you need coordinates for a map of your own, a route or a distance, because a pin gives you exact numbers instead of a text you have to geocode later and sometimes get wrong.

A map is also friendlier on a phone. Tapping a spot is quicker than typing a street name on a small keyboard, and the browser can offer to use the current location in one step.

Why OpenStreetMap and Leaflet

OpenStreetMap is a map made by volunteers and used by a large part of the web. Its data is free to use, as long as you credit it. Leaflet is a lightweight open source library that shows OpenStreetMap tiles in a page, with a marker you can drag, zoom controls and touch support. Together they remove three costs of the usual alternatives: there is no API key to create and protect, no billing account that can be charged when traffic grows, and no need to load a large third-party script. The add-on ships Leaflet in its own folder, so the page does not depend on a content delivery network either.

What the Visitor Sees

The field shows a search box, a Use my location button, the map and, below it, boxes for latitude, longitude and address. The visitor can click the map to drop a pin, drag it to fine tune, search for a place, or press the location button and let the browser share the position. When the pin lands, the address of that spot is looked up and written into the address box, and the visitor can correct it. Everything is plain text in the end, so a typed address and a found address look the same on the entry.

Set It Up in Five Steps

  1. Install and activate the add-on, then activate your license key in Forms → Settings → Map Picker.
  2. Enter a contact e-mail for the address service on the same page. It is sent with each lookup so the service can reach you if something goes wrong.
  3. In the form editor, add Map (OpenStreetMap) from Advanced Fields and set the start position: the latitude and longitude of the centre and a zoom level. Zoom 12 suits a city, 17 a street.
  4. Choose the tools: location button, search box, address lookup. Optionally pick an Address field to fill in.
  5. Open the form, drop a pin and check the entry.

Read This Before You Go Live: The Usage Policies

The free OpenStreetMap services are run by volunteers, and both of them have written usage policies that you should respect. This is the most important section of this post, because it is where map projects most often go wrong.

The tile server

The standard tile server at openstreetmap.org is for light use. It forbids bulk downloading, requires the credit OpenStreetMap contributors to be visible, and tells operators of busy sites to use their own tile server or a commercial provider. The add-on shows the credit by default and makes the tile server a setting. When your forms get real traffic, put the URL template of your own server or of a commercial provider into the field or the site settings, together with the attribution that provider asks for, and the standard server is no longer used.

The address service

Search and address lookup use Nominatim. Its policy asks for at most one request per second, forbids search-as-you-type, wants a way to identify your application and prefers that you run your own server for heavy use. The add-on follows each rule in practice. All maps on a page share a single queue that never sends two requests less than 1.1 seconds apart. Search runs only when the visitor presses Search or Enter and needs three characters. A pin that is being dragged or moved with the keyboard triggers one lookup, about a second after it stops. Each request carries the referrer of your site, which the browser adds, and the contact e-mail you entered. A page stops after sixty lookups. And in the settings you can switch lookups off completely or point the add-on at your own endpoint.

Because the requests come from the visitor’s browser, your own server sends nothing, and each visitor has their own IP address in the eyes of the service. That is gentler on the public service than sending everything from one server, but it also means your privacy policy should say that the browser contacts the map and address services. The add-on adds suggested wording to the WordPress privacy policy guide.

The Gravity Forms entry detail of a Report a problem entry showing the address and the coordinates of the pin, a small static map with the marker and the link Open in OpenStreetMap
On the entry: the address, the coordinates, a small map and a link to openstreetmap.org.

What Is Saved With the Entry

The field stores the latitude, the longitude and the address as three inputs. Coordinates are saved with up to six decimals, which is roughly ten centimetres, and a position is only saved when both numbers are valid. The address is one line of plain text, up to 500 characters. On the entry detail page you get a small static map and a link to open the point on openstreetmap.org, and in notification e-mails the full field shows the address, the coordinates and the link.

Using the Position in Notifications and Logic

Merge tags give you each part separately. With a field labelled Problem location and the ID 5, the tags are the label, a colon, the ID and a part: lat, lng, address, coords or link. You can put the OpenStreetMap link into the e-mail to your maintenance team, or the coordinates into a webhook. Conditional logic can show an extra question when a pin has been dropped, or hide a block until the map is filled in. For a strict test of a real position, use the latitude input of the field in the rule.

Filling an Address Field From the Pin

Many forms still need a structured address for billing or dispatch. In the field settings you can choose an Address field of the same form. When the visitor picks a place, the street, city, state, ZIP code and country boxes are filled in. House number first for English sites, house number last for most others. The visitor can still edit each box, and a country list is matched by name.

A Request a bench form with a map and a Street address field: after the pin was dropped the street, city, state, ZIP code and country boxes of the Address field were filled in automatically
The pin also fills a Gravity Forms Address field: street, city, state, ZIP and country.

Built for Real Forms

A map inside a form has to cope with the ways forms behave. On a multi-page form the map on the second page is hidden when the page loads, so the add-on resizes it when the page is shown and loads its tiles then. When conditional logic reveals the map, it does the same. After an AJAX validation message the map starts again with the pin and the typed address kept, and it starts only once. With Save and Continue, the saved pin comes back on the resume link with the map centred on it. A form can have several maps, each with its own centre and zoom, and a page can hold several forms.

Accessibility Matters More on a Map

Maps are hard for keyboard and screen reader users, so the field does not depend on the mouse. The map can be focused with Tab, and pressing Enter drops a pin at the centre. The pin can be focused and moved with the arrow keys, further with Shift, one pixel at a time with Alt, and removed with Delete, and every change is announced in a polite status line. The latitude, longitude and address boxes are ordinary labelled inputs, so anyone can complete the field by typing. If the map pictures fail to load, the visitor is told and can type the numbers and submit the form anyway.

Tips

  • Start the map where your visitors are. A map that opens on your city is much easier to use than a view of the world.
  • Put a short instruction in the field description, such as Tap the spot where the problem is.
  • Keep the address box visible. Visitors often fix a street name by hand.
  • Test with a phone, with a keyboard only, and with the tile server switched off.
  • Enter a contact e-mail and read the two policies before you publish.

For Developers

Three PHP filters let you change the tile server of a map, the settings of the address service, and the configuration printed for one map, such as its centre and zoom. A small JavaScript function resizes the maps when you show a hidden container yourself.

// Use a commercial tile provider for one form and show its credit.
add_filter( 'gfxosm_tiles', function ( $tiles, $field ) {
    if ( 12 === (int) $field->formId ) {
        $tiles['url']         = 'https://tiles.mapprovider.invalid/{z}/{x}/{y}.png';
        $tiles['attribution'] = 'Map data by <a href="https://mapprovider.invalid/credits">Map Provider</a>';
        $tiles['maxZoom']     = 20;
    }
    return $tiles;
}, 10, 2 );

// Point address search and lookup at your own server.
add_filter( 'gfxosm_geocoder', function ( $geo ) {
    $geo['endpoint'] = 'https://geo.mycompany.invalid';
    return $geo;
} );

// Start every map in one form on the same city, one zoom level closer.
add_filter( 'gfxosm_field_config', function ( $cfg, $field, $form ) {
    if ( 12 === (int) $form['id'] ) {
        $cfg['lat']  = 52.5200;
        $cfg['lng']  = 13.4050;
        $cfg['zoom'] = 13;
    }
    return $cfg;
}, 10, 3 );

Frequently Asked Questions

Do I need a Google account or key?

No. The map is OpenStreetMap, drawn with Leaflet, and nothing needs an account or a key.

Can I use another map style or a paid tile provider?

Yes. Enter its tile URL template and attribution for the whole site or for one field.

Is the free service fine for my busy website?

No. The public servers are for light use. Use your own or a commercial tile server and your own address server, or switch the lookups off.

Does it work on phones?

Yes. The controls stack, buttons are touch-sized and the map takes a tap.

Which Gravity Forms versions does it support?

Gravity Forms 2.9 or newer with WordPress 6.5 and PHP 7.4 or newer. It is tested with Gravity Forms 2.9 and 3.1.

If you want to know where something is, let people show you on a map.

Let visitors show you where

A map field with a draggable pin, address search and no API key, built on OpenStreetMap and Leaflet.

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