// Set the center as Firebase HQ
var locations = {
"FirebaseHQ": [37.785326, -122.405696],
"Caltrain": [37.7789, -122.3917],
"ZyLAB_US": [38.8884, -77.1809],
"WhiteHouse": [38.8977, -77.0366],
"DC": [38.532000, -77.810000]
};
var center = locations["WhiteHouse"];
// Query radius
var radiusInKm = 1.0;
// Get a reference to the Firebase public transit open data set
var transitFirebaseRef = new Firebase("https://publicdata-transit.firebaseio.com/");
var geoFireRef = transitFirebaseRef.child("_geofire");
var hashes = geohashQueries(center, radiusInKm*1000);
log(JSON.stringify(hashes));
hashes.forEach(function(hash) {
var query = geoFireRef.child('i').startAt(null, hash[0]).endAt(null, hash[1]);
log('query from '+hash[0]+' to '+hash[1]);
query.on('child_added', function(snapshot) { log(snapshot.name()); });
setTimeout(function() {
log('stopping query from '+hash[0]+' to '+hash[1]);
query.off('child_added');
}, 15000);
});
function log(msg) {
document.getElementById('log').innerText += msg + "\n";
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.