Firebase Queries Not Working On Android Even Though The Reference Retrieves Data
Solution 1:
Firebase queries return a subset of the child nodes in a list.
So if you have a list of locations:
locations: {
location1: { lat:42.010185, lon:-33.010185 },
location2: { lat:-11.19645, lon:52.461219 },
location3: { lat:33.14518, lon:-11.128746 }
}
You could query the locations with:
ref.child("locations").orderByChild("lat").startAt(-12.0).endAt(-10)
Your data is missing a level: you're querying test
, but are missing the location1
, location2
, location3
level that I have under it. If you add such a level, your query will be able to match the child.
Your next problem is likely going to be that Firebase Database queries can only order by/filter on a single property. That means that for geo-queries, you can currently only filter on longitude or on latitude, which makes for only half a geo-query. I recommend that you look into GeoFire, which is our library for geo-querying. It combines latitude and longitude of each item into a single geohash value, which can then be queried.
Post a Comment for "Firebase Queries Not Working On Android Even Though The Reference Retrieves Data"