Reputation: 7405
I'm trying to implement locational based query in Firebase without GeoFire (Since the last update was 6 months ago it seems deprecated)
Anyhow, I can't figure this out.
It's not firing the listener. When there's not starting at or ending at it works.
Query looks like so: (Just testing with Latitude)
// Testing, only doing longtude atm.
geoFlamesFIRReference
.queryStarting(atValue: coordinates!.longitude - radius, childKey: "longtitude")
.queryEnding(atValue: coordinates!.longitude + radius, childKey: "longtitude")
.queryLimited(toFirst: UInt(Constants.LIMIT_OF_FLAMES_ON_MAP))
.observe(.value, with: { snapshot in
print("New location?")
})
Then example of some of my data:
Upvotes: 0
Views: 493
Reputation: 598708
You're using the wrong syntax for querying:
geoFlamesFIRReference
.queryOrder(byChild: "longtitude")
.queryStarting(atValue: coordinates!.longitude - radius)
.queryEnding(atValue: coordinates!.longitude + radius)
Note that you will run into problems when you also want to filter by latitude, as Firebase queries can only contain a single orderBy
clause.
GeoFire uses geohashes to work around this limitation. So if you're intent on not using that library, you will have to read up on those.
Upvotes: 1