1

I'm new to Geofire and I wonder whether it's possible to get the full data that matches the Geoquery. For example, if I point my Geofire reference to my user and every user has his or her own location. By specifying the radius and center I want, ideally, I want to retrieve some sort of snapshots that contains a list of users given that center and radius instead of just the user ids and the locations information. From the doc here, it only has an example get all the keys(since we are passing user id as the key when we created those geo locations, they will be the key retrieved from the observeEventType method below) that match the query, like so

var queryHandle = query.observeEventType(.KeyEntered, withBlock: { (key: String!, location: CLLocation!) in
  println("Key '\(key)' entered the search area and is at location '\(location)'")
})

Otherwise, I have a make a query for each user to load their additional information, which is not good for actual practice.

Thanks

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Kesong Xie
  • 1,316
  • 3
  • 15
  • 35
  • GeoFire keeps the location information and the other object data in separate location, since these two data sets are often updating at different intervals. Doing an extra call for each key from you geo query is not as slow as you may think, since Firebase pipelines the request. See http://stackoverflow.com/questions/35931526/speed-up-fetching-posts-for-my-social-network-app-by-using-query-instead-of-obse/35932786#35932786 for an explanation of that. – Frank van Puffelen Oct 15 '17 at 17:14
  • So there is no way I can retrieve all my record based on the center and radius? and I have to go through getting the keys first and make individual call? – Kesong Xie Oct 15 '17 at 17:21
  • You indeed have to load each item separately. Read my answer to the question I linked in my comment to learn why that isn't as slow as you may think. – Frank van Puffelen Oct 15 '17 at 17:50
  • Great read, thanks! – Kesong Xie Oct 16 '17 at 06:21
  • It can be done by just small tweak and end result will be very optimised for large dataset, follow the steps I have mentioned here, It is working fine for me for radius based queries https://github.com/firebase/geofire-objc/issues/101 – Muhammad Adil Mar 17 '18 at 14:13
  • @FrankvanPuffelen your approach is really making sense but it is always good to save extra load over firebase. I mean if you can already get records than better use them. – Muhammad Adil Mar 17 '18 at 14:15

0 Answers0