Created
August 16, 2011 18:36
-
-
Save patrickarlt/1149804 to your computer and use it in GitHub Desktop.
socket.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socketio_connect = "http://subscribe.geoloqi.com:80"; | |
var thePath = false; | |
function start_realtime_streaming() { | |
// Load up the history of the trip prior to this page loading | |
$.getJSON("/platform/share/history.json", { | |
token: share_token | |
}, function(data){ | |
var historyLine = new google.maps.Polyline({ | |
strokeColor: "#000000", | |
strokeOpacity: 0.8, | |
strokeWeight: 3 | |
}); | |
for(var i in data.points) { | |
var point = data.points[i]; | |
historyLine.getPath().push(new google.maps.LatLng(point.location.position.latitude, point.location.position.longitude)); | |
} | |
historyLine.getPath().push(new google.maps.LatLng(last.location.position.latitude, last.location.position.longitude)); | |
historyLine.setMap(map); | |
}); | |
var socket = io.connect(socketio_connect); | |
socket.on('enter token', function(data) { | |
socket.emit('token', share_token); | |
}); | |
socket.on('location', function(location) { | |
var loc = eval("("+location+")"); | |
receive_location({ | |
date_ts: loc.date_ts, | |
date: loc.date, | |
location: { | |
position: { | |
latitude: loc.latitude, | |
longitude: loc.longitude, | |
speed: loc.speed, | |
altitude: loc.altitude | |
} | |
} | |
}); | |
}); | |
// Poll the link to find out if it's expired | |
poll_expired(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment