I have Location class variable in the Firebase DB and I want to use distanceTo()
function like this:
adapter= new FirebaseRecyclerAdapter<Shops, MenuViewHolder>(Shops.class,
R.layout.menu_item,
MenuViewHolder.class,
shops.orderByChild("address").distanceTo(locationofusertocompare) )
How to do this thing and restrict items to be shown in RecyclerView
?
Unfortunately, there is no way in which you can filter database records, in the way you do. There is no distanceTo()
method in Firebase. To solve such a problem, you should use a third party library named Geofire :
GeoFire is an open-source library for Android/Java that allows you to store and query a set of keys based on their geographic location. Its main benefit however, is the possibility of querying keys within a given geographic area - all in realtime.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.