How to get the closest distance to my point

Could anyone help me please?
How can I get the closest distance between various latitude and longitude?

I’d build it using the Distance Matrix API: https://developers.google.com/maps/documentation/distance-matrix/overview
Also you can check this: http://community.thunkable.com/t/distance-matrix/1340/35
Good luck!

1 Like

Great question! I was just Googling this last night and there are definite methods (I’m going to check the example above) but I realized for me… I need to loop through a long list of objects (JSON) to see which is closest to a specific latitude/longitude pair and well, I think my object list would be too long to store in Thunkable. Hmm, maybe I could store it in an Airtable or Google Sheet.

Anyway, interested to see what you can figure out!

Thanks for the reply. I’ll see what i can do.

I’m working on the tutorial for this!!!

[UPDATE]
you’re looking to get a response like this back, right?

i create the milesToPoint property everytime the database is called using the URL scheme above.
i include only milesToPoint,state,city,objectId. everything done very quickly by the DB server. The search was conducted using arbitrary coordinates near my home!

without any fancy querying the response looks like this.

1 Like

I’m using the formula posted here: Calculate distance travelled.

I cycle through a list of lat/lon pairs to see which is closest and it works great. No API needed.

2 Likes

:mechanical_arm:.

Makes sense! I am creating a photo sharing app and wanted users to see/search for photos taken near them. The DB is always going to grow so I need the api. For a fixed data set, I’d take your rout too!

My backend does the heavy lifting way faster than any phone will (for now) Whatever works though! Each use case is unique!!

1 Like