Google-Maps-for-Craft icon indicating copy to clipboard operation
Google-Maps-for-Craft copied to clipboard

Search: show nearest entry on map

Open holhel11 opened this issue 9 years ago • 1 comments

holhel11 avatar Apr 25 '16 11:04 holhel11

Not sure exactly how this would tie in to your set up, but you can use a regular form to search for location, then get this from the url:

{% set location = craft.request.getParam('location') %}

Then you can pass that to get your results:

{% if location | length %}
    {% set params = {
        address: location,
    } %}
    {% set store = craft.entries.section('storeEntries')
                            .mapField(params)
                            .order('distance asc')
                            .limit(1)
    %}

That will give you your closest store, which you'll have to tie in to your existing set up.

Jammooka avatar Apr 29 '16 06:04 Jammooka