How to get user current city efficiently? (rough location)

I’m trying to get my app to get the current city of my user and display some touristic info.

Currently I’m doing it by having a sheet of supported cities and calculating the distance to each of them and selecting the one that’s closer than 20km.

The problem is that this won’t work when increasing the number of cities. I plan to have about 1000 entries in my cities list.

Free tier is very limited to the number of distance calculations. I have no problem paying for pro but it’s not clear how limited Pro is in the number of distance calculations.

Is there a more efficient way to get the current city of the user and lookup the stored information about it?

I think your method would work when scaling the number of cities up, just that its initial loading time will not be nice due to distance calculation, but that’s about it.

Won’t I immediately run up against the glide limits for calculating distances?

Do you plan to display the cities on a map? I’m only aware of the 1000 pins for map view, I’m not sure if the distance calculation is limited to 1000 as well.

No map. I just need the city each user is in so they can receive the local touristic info from my DB (of that single city they are currently in).

Then I would give it a try. How are you currently retrieving the closest city?

I sort the cities sheet by distance to user in ascending order and put a filter condition to only show the details of the city if the distance between user and city is less than 20km.

What are the distance calculation limits for pro? I’m just afraid this will fail as soon as I add more cities.

I can’t find a reference on Glide’s website but this is a recent comment from a fellow expert for you.

He has 8000 rows, it works, but it takes time to do so. I think 1000 would be fine. I have one app with almost 700 and it works normally.

1 Like

I gave up on it! The app would freeze every time :slight_smile:

2 Likes

There’s no limit in terms of distance calculations… But there’s an un fixed bug when you have a filter based on distance in an app that has been installed in a device

But there’s an un fixed bug when you have a filter based on distance in an app that has been installed in a device

I’m sorry I don’t exactly understand what you mean by this. What’s the bug?