0

I'm making a mobile app with React Native and Cloud Firestore and I'm having trouble querying data from the Firestore database.

I have a collection of restaurants documents that contains address data in firestore. I want to only read few(around 15) of them which is closest to the current user location. After querying, I will display them in the list. I'm thinking of using Haversine formula to query the documents with closest location. However, I have realized that only simple comparison is possible when using simple query methods. I have no idea how to read only those few documents without having to go through all the documents. What will be the solution? Thank you for your time in advance! Note that I'm very new to Firestore and coding in general.

  • Notice that Cloud Firestore doesn't specifically support queries based on geolocation, therefore this question doesn't have a straightforward answer. Nonetheless, I believe that you might find a good starting point by checking this similar posts within the community [1](https://stackoverflow.com/questions/46630507/how-to-run-a-geo-nearby-query-with-firestore) [2](https://stackoverflow.com/questions/46607760/how-to-query-closest-geopoints-in-a-collection-in-firebase-cloud-firestore). I hope they are useful. – Daniel Ocando Nov 18 '20 at 13:18
  • Does this answer your question? [How to query closest GeoPoints in a collection in Firebase Cloud Firestore?](https://stackoverflow.com/questions/46607760/how-to-query-closest-geopoints-in-a-collection-in-firebase-cloud-firestore) – Daniel Ocando Nov 18 '20 at 13:20
  • I've realized that Firestore doesn't support geoquery as I did my research. There are still points that I'm confused with but thank you for helping me! I hope you have a lovely day:) @DanielOcando – phyeony Nov 20 '20 at 17:15

0 Answers0