Skip to content Skip to sidebar Skip to footer

Limit The Number Of Queried Items From Geofire

I have a lot of entry in the same location. I would like only to get the 10 latest added items using Geofire. I know that it can be done easily with firebase using Query.limitToLas

Solution 1:

There is only one solution for this :

you should begin a query with a small radius,

and each time you reach onGeoQueryReady() ("All data has been loaded"), you increase the radius by a small amount of the geoquery with .setRadius(r) until you reach the limit you want

based on this https://github.com/firebase/geofire-js/issues/59

Solution 2:

There is no way to limit the number of keys from Geofire: it will return all keys that fall into the range you query for.

The only thing I can think of is to not insert items if there is already another item in its vicinity. You're essentially clustering items while writing to the database in that case.

Post a Comment for "Limit The Number Of Queried Items From Geofire"