Forum Academy Marketplace Showcase Pricing Features

Do all distance functions in Bubble use Google APIs?

I’m a bit confused. I have a Bubble app on its own domain and with the Google API keys set up.

I have data items with geographic addresses and on a page I return lists of those items searched for and sorted based on “distance”. There are no maps.

I assumed all of the distance functions used Google APIs, but I don’t seem to see them coming through in my Google dashboard’s metrics.

I’d actually be really happy if these functions didn’t use Google APIs as I fear it would become prohibitively expensive - I do a lot of distance stuff but it’s all quite basic. Simple “as the crow flies” (Haversine) distance calculations would be perfectly adequate - I don’t need them to be route based.

Is there any chance the distance search/sort stuff in Bubble uses its own calculations based on latitude and longitue, rather than using Google APIs?

Thanks, James.

Hoping someone can help with this. Ideally I’d just like to know what happens behind the scenes when I search for data ‘within 20 miles’ of current page’s location, and when the resulting list is sorted by distance.

Which APIs does it call (if any)? If I have 10 lists on a page with 3 items in each, is that 30 calls to a Google API per page load?

Just to reiterate, I’m not using maps at all, just distances based on geographic addresses.

Thanks.

If you need to calculate distance between coordinates, then there are two plugins for it. And you can calculate this dance without any API.

Thanks @shpak.serhiy. Which two plugins are those please?

And can you give me a couple of hints on how to populate a repeating group with e.g. all [things] that are within 20 miles of [this thing]?

James

ToolitKit https://bubble.io/plugin/toolit-kit---helpful-functions-1562812673262x109396480465567740
has distance plugin that calculate distance between two coordinates.

To create a list of all things within 20 miles you need to iterate your list of thing and calculate the distance between every thing from the list and “this thing”. If distance is <20 miles you can store it in a list or mark somehow.

If you have too many things and don’t want to iterate all of them (using API workflow or ListShifter) you could create four separate list of things based on Lon/Lat.

  1. lat > this thing lat
  2. lon > this thing lon
  3. lat < this thing lat
  4. lon > this thing lon

Than you stop iterate the list once you exceed the 20 miles distance and hence you won’t iterate the whole list of things.

Basically, it is a rough algorithm that you can build in Bubble.