[OpenLayers-Commits] r11213 - sandbox/cmoullet/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Feb 22 04:05:41 EST 2011


Author: cmoullet
Date: 2011-02-22 01:05:40 -0800 (Tue, 22 Feb 2011)
New Revision: 11213

Modified:
   sandbox/cmoullet/openlayers/examples/accelerometer.html
Log:
Fine tuning of accelerometer example

Modified: sandbox/cmoullet/openlayers/examples/accelerometer.html
===================================================================
--- sandbox/cmoullet/openlayers/examples/accelerometer.html	2011-02-22 08:54:42 UTC (rev 11212)
+++ sandbox/cmoullet/openlayers/examples/accelerometer.html	2011-02-22 09:05:40 UTC (rev 11213)
@@ -18,9 +18,12 @@
             if (isEventSupported('deviceorientation', window) || isEventSupported('mozorientation', window) || isEventSupported('devicemotion', window)) {
                 if (window.DeviceOrientationEvent) {
                     window.addEventListener("deviceorientation", function (event) {
-                        document.getElementById('resultDeviceOrientation').innerHTML = "Alpha: " + event.alpha + "<br>";
-                        document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Beta: " + event.beta + "<br>";
-                        document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.gamma + "<br>";
+                        document.getElementById('resultDeviceOrientation').innerHTML = '';
+                        if (typeof(event.alpha) != 'undefined') {
+                            document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Alpha: " + event.alpha + "<br>";
+                            document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Beta: " + event.beta + "<br>";
+                            document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.gamma + "<br>";
+                        }
                         if (typeof(event.absolute) != 'undefined') {
                             document.getElementById('resultDeviceOrientation').innerHTML = document.getElementById('resultDeviceOrientation').innerHTML + "Gamma: " + event.absolute + "<br>";
                         }
@@ -31,17 +34,19 @@
                 }
                 if (window.DeviceMotionEvent) {
                     window.addEventListener('devicemotion', function (event) {
-
-                        document.getElementById('resultDeviceMotion').innerHTML = "accelerationIncludingGravity.x: " + event.accelerationIncludingGravity.x + "<br>";
-                        document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.y: " + event.accelerationIncludingGravity.y + "<br>";
-                        document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.z: " + event.accelerationIncludingGravity.z + "<br>";
+                        document.getElementById('resultDeviceOrientation').innerHTML = '';
+                        if (typeof(event.accelerationIncludingGravity) != 'undefined') {
+                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.x: " + event.accelerationIncludingGravity.x + "<br>";
+                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.y: " + event.accelerationIncludingGravity.y + "<br>";
+                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "accelerationIncludingGravity.z: " + event.accelerationIncludingGravity.z + "<br>";
+                        }
                         if (typeof(event.acceleration) != 'undefined') {
-                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML +"acceleration.x: " + event.acceleration.x + "<br>";
+                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.x: " + event.acceleration.x + "<br>";
                             document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.y: " + event.acceleration.y + "<br>";
                             document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "acceleration.z: " + event.acceleration.z + "<br>";
                         }
                         if (typeof(event.rotationRate) != 'undefined') {
-                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML +"rotationRate.alpha: " + event.rotationRate.alpha + "<br>";
+                            document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.alpha: " + event.rotationRate.alpha + "<br>";
                             document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.beta: " + event.rotationRate.beta + "<br>";
                             document.getElementById('resultDeviceMotion').innerHTML = document.getElementById('resultDeviceMotion').innerHTML + "rotationRate.gamma: " + event.rotationRate.gamma + "<br>";
                         }
@@ -65,7 +70,8 @@
 <h1 id="title">Accelerometer</h1>
 
 <p id="shortdesc">
-    The goal of this script is to demonstrate the usage of accelerometer
+    The goal of this script is to demonstrate the usage of accelerometer.<br>
+    The orientation specification can be found <a href="http://dev.w3.org/geo/api/spec-source-orientation.html">here</a>.
 </p>
 
 <h1>Device motion</h1>



More information about the Commits mailing list