Reputation: 103
I have been using Firestore as a database for my project.
I have been building an app that stores paths which are generated by reading gpx files. The collection I use to store them is built like this:
Each document is a different trail path.
What I would like to do is conditionally search through the collection "paths". I have been reading this documentation : https://cloud.google.com/firestore/docs/query-data/queries?hl=en
The condition will be to return result which are with X kms using latitude and longitude values, which are stored in the nested array "coordonnees".
I would like to know if there is a way to use this kind of expression below to look for data where coordonnees.lat < X and coordonnees.lng < X for example ???
citiesRef.where("state", ">=", "CA").where("state", "<=", "IN");
The goal is that people will type their location, and I want to return them the stored files that are near the location they typed in. If you know a better or another way to reach the same goal, it would nice too!
Upvotes: 0
Views: 59
Reputation: 598951
If I understand you correctly, you want to find documents that are around a certain location. While Firestore has a GeoPoint data type built-in, it unfortunately not currently support performing geoqueries on those.
The best option is to use an add-on library based on geohashes, as explained in the documentation on performing geoqueries on Firestore.
Upvotes: 1