question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to query once for a given location and radius?

See original GitHub issue

Is there a way to query once for a given location and radius? I don’t want to get changes realtime in this use-case. Instead, I just need all the results once the query completes.

I’m looking for something similar to the once function in Firebase.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
jwngrcommented, Sep 17, 2015

Yeah, you can do this using the "ready" event listener. It would look something like this:

geoQuery.on("ready", function() {
  // This will fire once the initial data is loaded, so now we can cancel the "key_entered" event listener
  onKeyEnteredRegistration.cancel();
});

var onKeyEnteredRegistration = geoQuery.on("key_entered", function(key, location, distance) {
  console.log(key + " entered query at " + location + " (" + distance + " km from center)");
});
1reaction
rcubarochacommented, Sep 17, 2015

The Ready Event tells you when the initial data is loaded, sure, but what he’s asking is if there is any way to just get all the data for the matching keys in one swoop instead of listening for individual events for each one.

As things are I can either query Firebase for the actual object for each key returned by Geofire on every Key Entered Event or I can pool the keys until the Ready Event fires and then I make a query to Firebase for the objects of all the keys returned by Geofire.

Both approaches seem cumbersome in their own ways.

Is there another way of doing this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fast query of objects based on location and radius
To find all points within a search disk, traverse the tree while pruning nodes whose half-plane completely excludes the search disk. You'll have ......
Read more >
How to fetch database objects whose location is in a radius ...
This video demonstrates how to use the "Search in radius " feature to generate a where clause which can be used to run...
Read more >
Format location data to include a distance radius - Open Q&A
As you can see, the radius is set at query time, it is not part of the record data. So for a given...
Read more >
How to query on a radius using ZIP (Postal) code or a city and ...
Click on Select map filter in top left of map. Draw a box of the area that you'd like to include in the...
Read more >
Search with location radius - Laracasts
@varovas no, you do not need to know the distance each place is from each other. the distance column is calculated by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found