Limit the number of queried items from GeoFire

耗尽温柔 提交于 2019-12-01 09:38:25

问题


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.limitToLast() but I don't know how to do it with Geofire.

If it is not possible, do you have any workaround that I can apply ?


回答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




回答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.



来源:https://stackoverflow.com/questions/38544974/limit-the-number-of-queried-items-from-geofire

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!