I am currently storing my locations within a firebase firestore database, they are organized by state as to reduce the search needed in the database. I would like the user to log in, and it returns 5 of the closest locations from my database based on the user location. I was planning on modifying the lat/long of the user and adding ~0.x in each direction to find the closest places, if nothing found then increase the x until 5 results are returned - this doesn't seem efficient. How can this be done in Firebase? Are there equations to create a circle instead of my box?
Asked
Active
Viewed 56 times
0

Frank van Puffelen
- 565,676
- 79
- 828
- 807

Pierre Louet
- 25
- 6
-
Have a look at the Firebase documentation on [performing geoqueries on Firestore](https://firebase.google.com/docs/firestore/solutions/geoqueries), which covers precisely that. – Frank van Puffelen Apr 19 '23 at 02:26