Skip to content

Templating ​

A Geo Maps field returns a location value (or null when nothing is set).

twig
{% set place = entry.storeLocation %}

{% if place %}
    <p>{{ place.full_address }}</p>
    <p>{{ place.lat }}, {{ place.lng }}</p>
{% endif %}

Properties ​

PropertyDescription
lat, lngCoordinates (floats)
zoomZoom level the map was at when the author saved the entry
full_addressThe complete formatted address
address1Street address, e.g. 1 King William St
suburbSuburb, town or city
postcodePostcode as text, so leading zeros (0800) and letters (SW1A 1AA) are kept
countryCountry name
countryCodeTwo-letter country code, e.g. AU
geoJsonDrawn shapes as a GeoJSON string
distanceDistance from the searched location — only set on location search results
addressAlias of full_address
partsThe address as { address, city, postcode, country, countryCode }

address and parts match the names used by other map plugins, so imported templates keep working.

Outputting the value directly prints the full address. Without an address it prints the shapes’ GeoJSON for shape-only values, or the coordinates:

twig
{{ entry.storeLocation }}

Methods ​

MethodReturns
hasCoordinates()Whether both lat and lng are set
getGeoJsonData()The GeoJSON decoded to an array, or null
length(unit)Total length of the value’s lines, in km (default), mi or m. See Trail Maps
area(unit)Total area of the value’s polygons with holes left out, in km2 (default), ha, m2, mi2 or acres
contains(place, country)Whether the value’s areas (polygons) contain an address, { lat, lng } or another value. country (optional, e.g. 'AU') narrows address lookups
embed(options)An interactive map centred on this location — see Maps
img(options) / imgSrcSet(options)A static map image URL — see Maps

Working with shapes ​

twig
{% set shapes = entry.storeLocation.getGeoJsonData() %}
{% for feature in shapes.features ?? [] %}
    {{ feature.properties.name ?? 'Unnamed' }} ({{ feature.geometry.type }})
{% endfor %}

Checking for a location ​

twig
{% if entry.storeLocation and entry.storeLocation.hasCoordinates() %}
    …
{% endif %}

To query entries that do or don’t have a location, see Location Search.