Created
November 9, 2013 11:53
-
-
Save sjg/7384664 to your computer and use it in GitHub Desktop.
Server Interaction Code to send Lat/Lng to be saved
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
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-2.0.1.min.js"></script> | |
</head> | |
<body> | |
<script src="http://www.stevenjamesgray.com:9090/socket.io/socket.io.js"></script> | |
<script> | |
var socket; | |
var sendData; | |
var getData, clearData; | |
//Alt in meters | |
var latLngData = { | |
lat: 55.1, | |
lng: -0.13, | |
alt: 80 | |
} | |
// Commands to Use | |
// sendData(latLngData); | |
// getData(); | |
// clearData(); | |
$(document).ready(function() { | |
socket = io.connect('http://www.stevenjamesgray.com:9090'); | |
socket.on('connect', function() { | |
console.log("Connected to Server"); | |
}); | |
socket.on('disconnect', function() { | |
console.log("Disconnected to Server"); | |
}); | |
socket.on('getAllData', function(data) { | |
console.log(data); | |
}); | |
sendData = function(latLngData){ | |
socket.emit("sendLatLng",JSON.stringify(latLngData)); | |
} | |
getData = function(){ | |
socket.emit("getData",{}); | |
} | |
clearData = function(){ | |
socket.emit("clear",{}); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment