Firestore:显示城市+半径内的所有数据

Firestore: Show all data which are in a city + radius

我想开发一个显示城市中所有餐厅 + 半径的应用程序。例如,用户输入汉堡并选择 50 公里的半径。现在显示了数据库中的所有结果,都在这个区域。

你如何做到这一点,你应该采取什么方法?

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

如果您需要允许用户浏览他们当前位置附近的餐馆,那么您正在寻找 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.

在这种情况下,您应该围绕城市中心创建一个半径。

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

在这种情况下,您应该为每个城市使用不同的半径值。例如,一个小城市可能需要在市中心周围 500 米,而一个大城市应该在市中心周围 2 公里。

或者,您可以让用户选择半径并根据它查询数据库。