Distance beetwen many relation in 2 tables

Here is my question: I have two tables with different addresses. I have created a relationship to be able to calculate a distance between them. However, when I create relationships based on streets, I get multiple results, but I cannot calculate the distance between each address. The goal is to be able to, from table A, find all the addresses in table B that are at a certain distance. Is this possible in Glide? Thank you.

“That are at a certain distance” from what?

I’ll assume that the user is in transport and would like to identify which locations within a list of n locations is within x distance, and the current location of the user is not fixed.

Layout Editor

  • Attach the tab either to the User table or its own table (which I called Current Location Tab)
  • Add a Location component
  • Add a collection of Locations

Data Editor

  • In the Current Location Tab table: Create a CurrentLocation basic text column
  • Create a Locations table:
    • Name (basic text),
    • Address (basic text),
    • LatLong (basic text),
    • CurrentLocation (Computed → Single Value → Location Tab → CurrentLocation),
    • DistanceWithAddress (Computed → Distance → CurrentLocation → Address),
    • DistanceWithLatLong (same with LatLong instead)
    • If-Then-Else: if DistanceWithLatLong is greater than 5km then false, else true (5km is an example)

Back in the Layout Editor

  • Configure your components by pointing fields to the right columns
  • Collection:
    • Make sur you set the data source correctly.
    • In Options → Filter Data, filter for If-Then-Else is true.
    • In Options → Sort Data, sort by DistanceWithLatLong is ascending (for example).

Note that in the example of 5km, instead of being fixed inside the configuration of the If-Then-Else column, could be variable, and this variable could be set by the user (number entry component, write to a Radius basic number column, and use this column in the configuration of the If-Then-Else column).

Also note that you can use either DistanceWithAddress or DistanceWithLatLong. You don’t need both, either one will work. DistanceWithLatLong is supposed to be more precise.

Thank u for your feedback but : I have a business in table A, and I have parking addresses in table B. I would like to know how to make each address in table A give me the closest parking spots from table B. I’ve tried to create relationships, but it gives me multiple results, which is logical, but I can’t know the distance for each. I hope you understand me.

How many addresses to you have in Table A, in Table B? Is the amount of addresses in Table A and Table B fixed?

The idea is that the user arrives at one of the locations in Table A and based on that information sees with parking spots in Table B are the closest, or the closest?

Hello, I have a table A with business addresses and a table B with parking spaces, and I would like to know how I can see the parking spaces that are close to the businesses in table A. I tried to calculate the distance, but it only works if there’s a single relationship, and in this case, each business may have multiple parking spaces related to it.

i think i need to make all the parking for all the shop but its to much time… and i dont know if is possible to make directly in Glide

How many business addresses are there in Table A? How many parking spots are there in Table B? Is the amount of addresses in Table A and Table B fixed?

the adress table A change when new user insert is shop, the adresse table B dont move its a data base from city i dont change this only sometimes.

a explain you : i have make a app for peaple around us can show her shop. a have table for user, table for shop , and table for parking for exemple… i have already make distance beetween user and shop but i need relation table B shop with parking place… i know i can make with google sheet for everyall adress shop and parking but its around 500 parking… and if i make one by one i died…ahahh

500 parking lots, ouch, I understand your predicament. I don’t have any good ideas, sorry.

Don’t worry i undestand… i search… if i have solution i post for everydoby… thank u so much for your help. Nice day

1 Like

Hello!
So, this is common google map feature may be, web view its enough?

hello, yes i can make like that but i need to use glide map it’s more confortable to view directly the places… I try to make calculate with google sheet with Lat/Long and variable for show the parking place and i try to put google sheet to Glide … if you have another solution. nice to you !

There are two solutions:

  • The complicated one would be a JavaScript column in the business
    table that could take in the location of the business and a list of parking locations, create a loop that would mathematically calculate the distance from the business to each parking location, and then return a list of the parking locations that fit your requirements.

  • Or, the easy way is to use a set column action to write the business location somewhere in a table, then use a single value column to bring the selected business location into the parking table and calculate distance in the parking table. Then set filters accordingly.

1 Like

thank u. i try to make script its work on google sheet ! but i try to calcul directly all the distance on one shop and all parking adress … … So long
i think its easy for me to make shop by shop and make all parking in the same street… after compiled all in one sheet… i’m thied for this since 3 days i search a solution…
i’m not far to make the solution but i don’t know why i whant make this possibility on the app … ahah

Sorry for my English!
We can fetch objects like this
https://overpass-api.de/api/interpreter?data=[out:json];(node(around:1000,55.7558,37.6173)[“amenity”=“parking”];);out;
then parse addresses and comparing to table and if they persists so to show objects from table

ok i undestand what you say… i try make possibility… i come back to you… Thanks

1 Like

If you whant to make distance ( like 50m ) beetween multitude adress correspondance in Table A to Table B.

  • For me the solution is to use Script from Google sheet and add the table to Glide.
    If you need the script let me know !

Best, Waouhh

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.