0

I have database structure having values of longitude and latitude as shown in image. enter image description here

Problem is, I want to Query for 'keys' that is in range of 5km. what I can do is read all the data and calculate the distance between these geopoints and mine geopoints, and select distance below 5km. But it will cost me lot of transactions and its not optimized way to do it.

I know geoquery is there, but I could not use Pagination there(not mentioned in docs). Anyone please help me out to find a way to query database or structure database, so could do locate key within 5 km.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
  • Since Firebase Realtime Database can only order/filter on one property, you can't query for both latitude and longitude with your current data structure. The solution is to add a geohash, which is a magical value that combines lat+lon into a single queryable value. There's an add-on library for Firebase called GeoFire, which I'd recommend checking out as it wraps the process nicely. – Frank van Puffelen Nov 11 '20 at 18:57
  • @FrankvanPuffelen but how to use pagination with geofire – abhishek verma Nov 12 '20 at 11:56

0 Answers0