From 0ce9d772e5f493373a9b531a2ae24d0fd8e15fb8 Mon Sep 17 00:00:00 2001 From: Joel Salisbury Date: Thu, 21 Jan 2016 15:07:28 -0500 Subject: [PATCH] testing altitude --- js/main.js | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/js/main.js b/js/main.js index 7b88530..700729c 100644 --- a/js/main.js +++ b/js/main.js @@ -1,24 +1,39 @@ -if (window.DeviceMotionEvent) { - window.addEventListener('devicemotion', deviceMotionHandler, false); -} else { - document.getElementById("warning").innerHTML = "Not supported." -} +// 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) +// 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; - } +// 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) { + x.innerHTML = "Latitude: " + position.coords.latitude + + "
Longitude: " + position.coords.longitude + + "
Altitude: " + position.coords.altitude; } \ No newline at end of file