Address within 5 miles of current location

Hi,

I am looking for some help to find out all the addresses stored in my database that are within X miles of a user's current location.  I have a data type that contains a text field for address, I can also have a field to contain ZIPcode if needed.  I am storing a list of users that register with my app along with their addresses.

I want to give the end user a search option to find all registered users within X miles of their current address. My front end is in Dropsource and API is in Bubble. Do I have to get store latitude/Longitude instead of text addresses and do the calculation on my own or is there a better approach to this.

Thank you

@sshobha23 - as you may know, Bubble has multiple “types” of fields (ie. text, date, number, etc).

When you want to be able to filter things based on an address, the corresponding field on the user profile should be saved as a geographic address, not text. This will enable you to use address as a search constraint.

This lesson on LearnTo will give you an introduction to geographic addresses as a constraint.

To keep in mind, a field formatted as geographic address has all of the constituent parts of an address and can be extracted, as needed. (Ie. since it’s pulling from Google, you can find meta information about the address - Zip code, country, etc).


Dan (creator of LearnTo - 15+ hours of Bubble tutorials and live coaching)

1 Like

Hi,

I am using google's autocomplete api to fetch the initial address in dropsource. The response I get from this api is in a string format. Are you suggesting that I store this in a "geographic address" in bubble instead of text. Can you please clarify.

Thanks,

Yes, store it as a geographic address. That way, Bubble treats that piece of data as an address.

For your posts, it seems that you keep formatting your text of your post within code markings. (ie. text that's formatted like this). Unless it’s actual code, it’s easier to leave it as plain text for ease of readability.

thank you. I did not do any formatting of my post so I do not know what I should be doing to show it differently.

Make sure your text doesn’t have ` symbols around it. (If you copy paste text from somewhere else, there is a chance it picks up on that. As well, clicking the </> button automatically inserts that formatting.

Understood. Thank you

1 Like

Thank you for the response. When I use a search box and type into the input field it shows up the list of geographical places like it does in the sample you have shared a link to. However when I try to fetch the value from the search box input, it shows the value as empty.

I am not able to figure out where I am going wrong