Map field
What it does
A Map field shows a Google map on the form. The visitor clicks the map to place a pin, or types a place into the Search box at the bottom of the map. The field saves the address of the pin. When Google can't name the place, it saves the pin's coordinates instead. You find the field in the builder's left panel, in the Advanced group, and add it by dragging it onto the form, as described in Adding fields and sections.
Before you start
The map needs a Google Maps API key, entered in Stores → Configuration → MageMe Extensions → WebForms → Integrations → Google Maps → Google Maps API Key. See Integrations. Google Maps Map ID in the same group is optional: with a Map ID, the map shows Google's current marker; without one, it keeps the classic marker.
Without a key, the map isn't shown to visitors at all. The rest of the form works and can be sent. In the builder, the field shows the warning "Google Maps API key is not set" and "The map is hidden on the storefront until the key is added.", with the link Open Google Maps Settings. When only some store views lack a key, the warning names them. The form's settings page shows the same warning.
A Required Map field is treated differently: a form whose required map would be hidden in one of its store views can't be published, and can't be switched on, either for all store views or for a store view without a key. Add the key first, or turn off Required on the Map field.
When to use
- Use Map when a place matters more than a written address: a delivery point on a large site, the spot of a damaged fence.
- For a postal address, use an Address field.
Settings
Go to Content → WebForms → Manage Forms, click the form's name, then click Form Builder. Click the field on the form. Its settings show in the right panel, on the tabs General and Appearance. You'll change these settings most often:
- Default Address (General tab) is where the map opens, such as your city.
- Default Latitude and Default Longitude set the opening point by coordinates instead.
- Default Zoom sets how close the map opens. A new field opens on the whole world.
- Required makes the visitor place a pin before sending.
When the field has no Default Address and no coordinates, the map asks the visitor's browser for their location, and the browser may ask the visitor to allow it. If they allow it, the map shows where they are. To keep the map from asking, set Default Address or the coordinates.
The table below lists every setting. Visitors see a change after you click Publish Changes in the builder's top bar.
All settings of this field
| Setting | Where in the panel | Values | Translatable |
|---|---|---|---|
| Enable Field | General → Basic | On or off | No |
| Label (required) | General → Basic | Text | Yes |
| Field Code | General → Basic | Text | No |
| Required | General → Basic | On or off | No |
| Required Error Message | General → Basic | Text | Yes |
| Help Text | General → Basic | Formatted text | Yes |
| Tooltip | General → Basic | Formatted text | Yes |
| Default Address | General → Field Settings | Text | Yes |
| Default Latitude | General → Field Settings | Number | No |
| Default Longitude | General → Field Settings | Number | No |
| Default Zoom | General → Field Settings | Number | No |
| Hide in Submissions | General → Submission Display | On or off | No |
| Allow in Staff Email Subject | General → Submission Display | On or off | No |
| Submission Label | General → Submission Display | Text | Yes |
| Personal Data | General → Privacy | By field type — Personal data, Not personal, Personal data | No |
| Desktop | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Tablet | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Mobile | Appearance → Layout | Width: Full (1/1), Half (1/2), Third (1/3), Quarter (1/4), Fifth (1/5), Sixth (1/6), 2/3, 3/4, 2/5, 3/5, 4/5, 5/6; New row: on or off | No |
| Show Label | Appearance → Style | On or off | No |
| Help Text Position | Appearance → Style | Below input, Above input | No |
| Container Classes | Appearance → CSS | Text | No |
| Input Classes | Appearance → CSS | Text | No |
| Custom Attributes | Appearance → Advanced | Text | No |
| Inline Style | Appearance → Advanced | Text | No |
Validation
| Check | What the visitor sees when it fails |
|---|---|
| Required, no place chosen, with a key set | "This is a required field." under the map. |
Logic
- Start a rule: no. A Map field can't start one. Its Logic tab appears only once a rule shows or hides it, and lists that rule.
- Show or hide this field: yes, from a rule that starts on a field with options. See Show or hide fields and sections.
Limits
- Google no longer offers the place search behind the Search box to new customers of Google Maps. If you started using Google Maps recently, the box may find nothing; clicking the map still places the pin.
- An answer left empty doesn't appear on the submission page or in emails with all answers.
- In the Management API the field counts as personal data and comes back masked. See Personal data masking.
Troubleshooting
- The map doesn't show on the form. No Google Maps API key is set for this store view. Enter one, as described in Before you start.
- The map area shows an error from Google instead of the map. Google refused the key. In your Google Cloud project, check that the key may be used on your store's address and for the three APIs the field uses: Maps JavaScript API, Places API and Geocoding API.
- Publishing says the required map "would be hidden on the storefront". The form has a Required Map field and no Google Maps API key. Add the key, or turn off Required on the Map field, then publish again.
- Submissions show numbers like
32.63;-87.18instead of an address. Google couldn't name the place. The numbers are the latitude and longitude of the pin.
What's next
- Integrations: enter the Google Maps API key.
- Address field: ask for a postal address.