title: Fetch list of restaurants in user's proximity using Firebase-GeoFire
body: <p>I have a list of restaurants each of which has a fixed location which is stored in GeoFire. Now I want to display the restaurants within a fixed radius of user location. How can I achieve this using GeoFire. The documentation here, <a href="https://github.com/firebase/geofire-js/blob/master/docs/reference.md#geofiresetkeyorlocations-location" rel="nofollow">https://github.com/firebase/geofire-js/blob/master/docs/reference.md#geofiresetkeyorlocations-location</a> mostly suggests solutions in which geofire 'keys' are moving which are handled using key_entered, key_exited etc. But I'm not able to figure out how to access the keys in proximity.</p>
  
  <p>My controller code looks like:</p>
  
  <pre><code>var ref = firebase.database().ref();
  var geoFire = new GeoFire(ref.child("geofire"));
  var posOptions = {timeout: 10000, enableHighAccuracy: false};
  $cordovaGeolocation.getCurrentPosition(posOptions).then(function (position) {
  $scope.rest= [];
  $scope.filteredRest = [];
  var geoQuery = geoFire.query({
    center: [position.coords.latitude,  position.coords.longitude],
    radius: 15
  });
  geoQuery.on("key_entered", function(key, location, distance) {
    console.log(key);
    $scope.filteredRest.push(key);
  });
  geoQuery.on("ready", function() {
    geoQuery.cancel();
  });
  console.log($scope.filteredRest);
  </code></pre>
  
  <p>The key is printed on console but is not pushed to filteredRest array. </p>
  
  <p>I'm looking to achieve 'Example usage' in following link:
  <a href="https://github.com/firebase/geofire-java#example-usage" rel="nofollow">https://github.com/firebase/geofire-java#example-usage</a></p>
  
  <p>There are similar questions but most of them are in ios/swift and the answers are not very informative. I'm using GeoFire-JavaScript. Any help would be appreciated.</p>