Bubble Geographic search constraint type


#1

Hi @sue,
I’m trying to filter a bubble search results based on a geographic location but i can’t seem to find the Geographic search constraint type among the Constraint types defined in the Add Bubble API Constraint action as shown below.
I want to restrict my search results to a certain radius within the current user’s location.

From bubble’s documentation on constraint types, there is the Geographic search type as shown in the snapshot below.
If this is currently not supported could you please add it as feature request? It’s really important for bubble-backend applications involving some geographic addresses.
There is a work around to use an api workflow but the Get Data from API action in bubble is limited to only 50 rows/entries.


#2

Hi @seanhoots, I don’t believe the geographic option was added when the plugin for the Bubble constraints was developed but am not sure if there was a reason. I’ll find out what the situation is with it and let you know.


#3

@seanhoots is there any solution to this as yet>?


#4

Dropsource hasn’t implemented it yet.

But you can use bubble’s api workflow with the geographic location functions do the filtering.


#5

hi @seanhoots thank you for reaching out.

Do you mean using the iterate through array, and if else the calculated distance is < say 100 miles, then add pins to map functionality?
I tried doing this method, and this works only to help put pins on the map. But I don;t know how to do it for dynamic tables.

Or do you mean using the google places ?
Please advise, as I have been trying to do it so many times and I cannot seem to find another way.


#6

No I meant doing the filtering in bubble instead of doing it at Dropsource’s end.

You create an API workflow endpoint in bubble and use the Return Data from API action in bubble and in the return data you filter the results based on the location.
Something like this:

Then

ref_loc is a parameter of type geographic location .

Note that as I mentioned in the original post above there is a 50 items limitation imposed by bubble when you use an api workflow to return results.
So if you know your results will always be less than 50 this work perfectly else always only the top 50 results will be returned.
If that is ok for your use case you can sort the results so that the most relevant once are on top.
In my example above i sorted by the locations that a closest to my reference location.
So in this case always up to the 50 closest locations to my reference location will be returned.

Hopefully Dropsource will add this bubble constraint so that we can do it in dropsource and be able to return any number of results.
I’m still not sure why this particular constraint was excluded when the implemented the bubble constraints because it is very important constraint when dealing with app that have some location functionalities.


Filtering dynamic table using api array filter ( like in the tutorial)
#7

wow thanks @seanhoots I will start working on this. thanks alot. you the best. Happy new year


[Resolved] How do I apply geographic location constraints
#8

@seanhoots So this api is a post api, and should i also have the get/events/api along with it. that data source of the post/api only shows me no results.
Please advice.


#9

All Bubble API workflow endpoints are are POST.


#10

We’ve pinged the engineering team re adding the geographic constraint type, not sure if there was maybe a reason for not including it in the first place but will let you guys know when we have an update!


#11

hi @seanhoots so if i run this post/api request, will it automatically filter out the events from the get/api request.

or do i have to bind the results of the post/api elsewhere ??

I have never used this return data from api feautre until you showed it to me.


#12

@seanhoots i am really not sure how to work with this return api. I tried running it before the get/event api request to see if the events will be filtered but it doesnt.
Under the response tab of post/api for the results i binded it to a dynamic table and didn’t get any results as well.


#13

i have my layout like this.


#14

@seanhoots maybe I am missing out somewhere. PLease advise


#15

Note that when you use the Get data from API action to return data from an endpoint even if you specify the result as an object type, Bubble only returns the unique id of the object (see this bug report i filed in the bubble forum).
So i’m guessing you’re only seeing a single string response parameter from your api endpoint.

To fix this you have to edit your swagger to force it to return an object instead of the object’s id.
Search this forum for “Return data from api” and i’ve showed how to do this manual editing of the swagger to return an object with all its fields instead of the id of the object.


#16

It worked. Thank you so much for your help as always.


#17

Fantastic community collaboration here! We’ve brought this topic up and it will be researched in more detail internally. Thank you for bringing this up again both of you and thank you @seanhoots again for sharing your expertise on these matters with the community.