Smart Map

Documentation  •  Changelog


Filtering out entries with invalid coordinates

You can pass a "hasCoords" parameter to show only locations with valid coordinates...

{% set params = {
    hasCoords: true
} %}

{% set entries = craft.entries.myFieldHandle(params).all() %}

The resulting entries will exclude any locations that did not have a valid set of coordinates. Coordinates are only valid if both the latitude and longitude values are populated.


This can also be done in PHP...

use craft\elements\Entry;

$entries = Entry::find()
        'hasCoords' => true