javascript - Query Geofire for top X number of records in the area? -


trying wrap head around geofire, time being lets firebase database ranks bars on u.s. firebase query in case return rated list of top 100 bars in country. if map zoomed out whole country geofire return top 100 bars in country? in addition if map zoomed new york, geofire return top 100 in new york? in other words, want return top 100 given viewing area, list changes list moves around. can handle this? if so, example out there can see?

thanks in advance!

you can use geoquery set center , radius zooming in , out

var geoquery = geofire.query({    center: [10.38, 2.41],    radius: 10.5  });    var center = geoquery.center();  // center === [10.38, 2.41]  var radius = geoquery.radius();  // radius === 10.5    geoquery.updatecriteria({    center: [-50.83, 100.19],    radius: 5  });    center = geoquery.center();  // center === [-50.83, 100.19]  radius = geoquery.radius();  // radius === 5    geoquery.updatecriteria({    radius: 7  });    center = geoquery.center();  // center === [-50.83, 100.19]  radius = geoquery.radius();  // radius === 7

for top 100 can use approach when receive 100 element current geoqery, call cancel.

var geoquery = geofire.query({    center: [10.38, 2.41],    radius: 10.5  });    var bars = []    var onkeyexitedregistration = geoquery.on("key_exited", function(key, location, distance) {    console.log(key + " exited query " + location + " (" + distance + " km center)");    bars.push(key);    if(bars.length>=100)    {      geoquery.cancel();    }  });

reference doc


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -