Filtering by distance from a location in Repeating Group

I have Users stored with each User having a Location, which is a geographic address.

I show these Users in a Repeating Group, and on the same page is a Drop Down using the Countries Plugin | Bubble Plugin. When the input value of the DropDown is changed, it changes the State of the RG to sort the Users in the RG by Location distance from the value in the DropDown. At least that is what I am trying to do but I can’t get just use the Countries Dropdown value.

I would have thought I should be able to set it up identical to this: What happened to sort by distance from? - #2 by boston85719

Here is my setup:

I’ve never used that plugin but there is a value of 's latlng which is the latitude and longitude of the country…my assumption would be it is a centered location of the country, or perhaps the coordinates of its capital city, I have no idea.

I don’t know how that plugin provides that data but my suspicion is that it is as single string…something like (1.345678, -2.334545)…in which case to turn that latitude and longitude into a geographic address you need to use the calculate formula geographic address and use the value of the coordinates.

To extract the latitude from the coordinate string you need to use extract with regex

Screen Shot 2021-03-28 at 11.07.18 PM

To get the longitude you need extract with regex and find and replace to remove the comma

Screen Shot 2021-03-28 at 11.07.30 PM

And that should do it for you, but again I’ve never used that plugin and have no idea what the actual location of the coordinates is referenced to or how the 's latlng is actually provided.

I’m struggling to manage the above. :confused:

In the previous thread I linked, where is “Input A” getting its value? That must be geographic data too, but it’s not coming from a plugin?

/edit - ok I have given up on doing this based on a dropdown. Instead I can do it based on the geographical location of the user, if they allow location based services.

So I switched to sort by distance from Geographical Location. However, I now find that if the browser blocks location, then instead of just showing a default order, the Search returns no results at all. This doesn’t seem like the best way to handle this, as many people will not have location enabled in their browsers. Any ideas?

Yes…the method I outlined in my first response should work if you get it set up properly.

Reference this forum post on more detailed instructions on how that process works

If you are still struggling feel free to reach out via PM to set up a private 1:1 training session. Besides running Bubble Bootcamps I also provide private 1:1 and private group training sessions.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.