I'm pretty new on Firebase, I'm trying to follow this tutorial in Firebase's documentation: https://www.firebase.com/docs/open-data/transit.html
But I am really stuck.. Or better, I am completly lost. Nothing appears on the screen.
<head>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script src="https://cdn.firebase.com/js/client/1.0.18/firebase.js"></script>
<script src="https://www.firebase.com/resources/js/publicdata/transit.js"></script>
<script>
// Lookup all buses on line "X".
var transitLine = "5";
var transitRef = new Firebase("https://publicdata-transit.firebaseio.com/ttc");
var lineIndex = transitRef.child("routes").child(transitLine);
lineIndex.on("child_added", function (snapshot) {
var id = snapshot.name();
transitRef.child("routes").child(id).on("vehicles", busUpdated);
});
lineIndex.on("child_removed", function (snapshot) {
var id = snapshot.name();
transitRef.child("routes").child(id).off("vehicles", busUpdated);
});
function busUpdated(snapshot) {
// Bus line "X" changed location.
var info = snapshot.val();
// Retrieve latitude/longitude with info.lat/info.lon.
}
</script>
</head>
<body>
<div id="map_canvas" style="position:relative;width:600px;height:400px; border: 1px solid #ccc; margin: 0 auto;"></div>
</body>
Someone knows what am I doing wrong?
transit
. You probably are looking forroutes
.var lineIndex = transitRef.child("routes").child(transitLine);
– Frank van Puffelenon("vehicles"
. I've never seen an event calledvehicles
and doubt it exists. Do you meanchild("vehicles").on("child_added"
? – Frank van Puffelen