Searching by Distance
I have a few questions regarding searching by distance.
1) We have a few hundred entries, almost all of which have an address and lat/long set. However, it has come to our attention that there are several "national" locations that just serve everyone. Logically speaking, is it viable to set up some kind of indicator (a channel field that gets ticked perhaps) that if ticked, the result comes up in any distance search, since the entry technically is available at any distance?
2) Do you have a recommendation for a service/script that plays nice with EE2/Low Search for providing the lat/long pair to use for distance comparison?
Replies
Low 8 Nov 2018 07:30
1) I'm afraid not. Triggering the Distance filter will always limit entries to those that have lat/long applied and fall within the given radius. Adding other entries to those results would require some sort of OR logic (entries that fall within the range OR that have X), which is something that's just not possible using parameters in EE -- all filtering parameters are always combined with AND.
Instead, you could perhaps generate a second list of results (using a second channel:entries or low_search:results tag) to display those 'anywhere' entries when the Distance filter is triggered. You could do that inside a Filters tag to get to the search parameters, look for a 'distance:from' value and display those entries when that's not empty.
2) Google's geolocation/geocoding API was fine, but now they're requiring a paid account attached to their service (or at least, free up until x requests). The trick is to capture the form submit with JS, then call the API and re-submit the form along with the received lat/long values.
watermelonkid 8 Nov 2018 19:20
OK, thanks.