Smart Map

Documentation  •  Changelog


"isEmpty" and "hasCoords"

To make Twig logic a little easier, the Address model now includes two new methods...


You can easily see if any parts of an address exist by using "isEmpty":

{% if not entry.myAddressField.isEmpty %}
    {{ entry.myAddressField.format }}
{% endif %}

The "isEmpty" detection does not include coordinates... It only cares if any of the address fields have been completed.


To check if a valid coordinate set exists, you can use "hasCoords":

{% if entry.myAddressField.hasCoords %}
    Latitude:  {{ entry.myAddressField.lat }}<br>
    Longitude: {{ entry.myAddressField.lng }}
{% endif %}

The "hasCoords" method ensures that both coordinates exist, and are numeric.