Closed EmptyStreets closed 10 months ago
Here's a snippet which covers the basics... I haven't tested it, but I'm 95% confident it will work.
This is adapted from the "Simple Example" shown on the Proximity Search page.
{# Get a "Location" entry #}
{% set entry = craft.entries.section('locations').one() %}
{# Use a set of coordinates as the search target #}
{% set target = {
'lat': entry.lat,
'lng': entry.lng
} %}
{# Configure the proximity search #}
{% set options = {
'target': target,
'range': 50
} %}
{# Find nearby "Labs" #}
{% set entries = craft.entries
.section('labs')
.myAddressField(options)
.orderBy('distance')
.all() %}
And here are a few links which should tie it all together...
Hope that helps! 🙂
Hello,
If I read correctly I can avoid relying on Google maps api while performing an internal proximity search if the starting point and the desired entries have geo coordinates defined.
What would be the working snippet for that?
Channels
Default radius of 50 miles.
Locations:![Screenshot_20230805-230755_Samsung_Internet](https://github.com/doublesecretagency/craft-googlemaps/assets/1551388/fdce95ae-bf8d-4738-84b7-f543ba592178)
Labs:![Screenshot_20230805-230947_Samsung_Internet](https://github.com/doublesecretagency/craft-googlemaps/assets/1551388/2f054f8d-056d-473e-8324-9257ca87ff79)
Thanks.