// Setup Angular Broadcast event for when an object enters our query
var geoQueryCallback = query.on("key_entered", "SEARCH:KEY_ENTERED");
// Listen for Angular Broadcast
$scope.$on("SEARCH:KEY_ENTERED", function (event, key, location, distance) {
// Do something interesting with object
$scope.searchResults.push({key: key, location: location, distance: distance});
// Cancel the query if the distance is > 5 km
if(distance > 5) {
geoQueryCallback.cancel();
}
});
// Setup Angular Broadcast event for when an object enters our query var geoQueryCallback = query.on("key_entered", "SEARCH:KEY_ENTERED");