The new Firestore DB allows me to store GeoPoints. Is there a way to query based on them?
So for example if each of my collections documents got a location
field of the type geopoint
.
How can I get the closest 10 documents to an arbitrary coordinate?
The documentation doesn't seem to cover this. I tried stuff like this:
someRef.where('location', '>', geopoint).limit(10).get();
Obviously this doesn't make much sense but I'm just trying out some stuff here 😅
We haven't exposed geoqueries yet, so currently there isn't a way to do this.
Historically, the Firebase Realtime Database used geohashes in a library called GeoFire--but given that we plan to expose actual geoqueries in the near future, we haven't updated that library to Firestore. To learn how to do something similar yourself though, have a look at this video.