Skip to content
Permalink
ce568095db
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
46 lines (37 sloc) 1.22 KB
// if (window.DeviceMotionEvent) {
// window.addEventListener('devicemotion', deviceMotionHandler, false);
// } else {
// document.getElementById("warning").innerHTML = "Not supported."
// }
// function deviceMotionHandler(eventData) {
// // Grab the acceleration from the results
// var acceleration = eventData.acceleration;
// var trimmedaccel = acceleration.x.toPrecision(2)
// switch (trimmedaccel >= 0) {
// case true:
// $("body").addClass('up');
// $("body").removeClass('down');
// break;
// case false:
// $("body").addClass('down');
// $("body").removeClass('up');
// break;
// }
// }
var x = document.getElementById("warning");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
x.innerHTML = "Geolocation is not supported by this browser.";
}
}
function showPosition(position) {
console.log(position);
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude +
"<br>Altitude: " + position.coords.altitude +
"<br>Heading: " + position.coords.heading+
"<br>Speed: " + position.coords.speed
}
setInterval(getLocation, 500);