Home > Enterprise >  Firestore: Show all data which are in a city radius
Firestore: Show all data which are in a city radius

Time:01-12

I want to develop an app that shows all restaurants radius in a city. For example, a user enters Hamburg and selects a radius of 50km. Now all results from the database are displayed, which are in this area.

How do you do this and what approach should you take?

CodePudding user response:

I want to develop an app that shows all restaurants radius in a city.

If you need to allow users to browse restaurants near their current location, then you looking for Firestore Geo queries.

But how can I include a radius around a city. In the example, only one point is set and a radius is drawn around it. I want to show all results in the city, so I would have to check which locations are within the city limits.

In this case, you should create a radius around the center of the city.

But if I draw a radius of 1km around the center of London, for example, then not all results in London are displayed.

In that case, you should use a different radius value for each city. For example, a small city might need 500m around the city center, while a big metropole should have 2km around the city center.

Alternatively, you can let the user choose the radius and query the database according to it.

  •  Tags:  
  • Related