Location field

The location field allows the editor to pick a location on a map.

myLocationField:
  type: location

This field definition creates the following input in the control panel:

A location field in the control panel

The location field uses Google Maps to display maps. You must specify a Google Maps API key in the field settings, see :doc:../advanced/settings.

Attributes

Property Description
defaultValue Specifies a default location. When not given, the field will pick a default location based on the locale of the current site.
group Starts a new field group.
instructions Additional instructions for this field in the control panel. Will be shown beneath the field label.
label The primary `label` of the input field in the control panel. When omitted, a label will be generated from the name of the field.
rules The validation rules of the field.
width The width of the field in the control panel.

defaultValue

Specifies a default location. When not given, the field will pick a default location based on the locale of the current site.

defaultValue:
  latitude: 52.51666667
  longitude: 13.4

Templating

Printing the location field returns the latitude and longitude values as a coma separated string.

label: Location field demo
fields:
  locationField:
    type: location
---
<img src="https://maps.googleapis.com/maps/api/staticmap?center={{ locationField }}&zoom=13&size=600x300&maptype=roadmap" />

latitude

Returns the latitude value.

{{ locationField.latitude }}

longitude

Returns the longitude value.

{{ locationField.longitude }}