imperiumlabs / GeoFirestore-iOS

GeoFirestore for iOS - Realtime location queries with Firestore
MIT License
127 stars 46 forks source link

How to fetch documents around a certain location #33

Open Isuru-Nanayakkara opened 4 years ago

Isuru-Nanayakkara commented 4 years ago

Hello,

This might be a simple question but I'm having a hard time trying to figure out how to do this.

I'm developing an iOS app which transmits user's last known location periodically. My Firebase setup looks like this.

Screenshot 2020-05-18 at 18 12 28

It has a users collection. Each user has the aforementioned last location coordinate.

What I'm trying to do now is, given a location and a radius, fetch the set of users who fall within that radius.

I know I can initiate a query like this.

let circleQuery = geoFirestore.query(withCenter: center, radius: 10)

But not sure what to do after that. How do I get the results from this query?

fury21 commented 4 years ago

Look answer hear - https://stackoverflow.com/questions/46630507/how-to-run-a-geo-nearby-query-with-firestore