[OpenLayers-Commits] r11184 - sandbox/cmoullet/openlayers/examples
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Mon Feb 21 09:54:25 EST 2011
Author: cmoullet
Date: 2011-02-21 06:54:25 -0800 (Mon, 21 Feb 2011)
New Revision: 11184
Added:
sandbox/cmoullet/openlayers/examples/accelerometer.html
Log:
Add an example of usage of orientation (http://dev.w3.org/geo/api/spec-source-orientation.html)
Added: sandbox/cmoullet/openlayers/examples/accelerometer.html
===================================================================
--- sandbox/cmoullet/openlayers/examples/accelerometer.html (rev 0)
+++ sandbox/cmoullet/openlayers/examples/accelerometer.html 2011-02-21 14:54:25 UTC (rev 11184)
@@ -0,0 +1,65 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
+ <meta name="apple-mobile-web-app-capable" content="yes"/>
+ <title>OpenLayers Accelerometer Usage</title>
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css"/>
+ <link rel="stylesheet" href="style.css" type="text/css"/>
+ <script type="text/javascript" src="browser.js"></script>
+
+ <style type="text/css">
+ .olControlAttribution {
+ bottom: 5px;
+ }
+ </style>
+ <script type="text/javascript">
+ var result = document.getElementById('result');
+ function init() {
+ console.log(isEventSupported('deviceorientation', window));
+ if (isEventSupported('deviceorientation', window) || isEventSupported('mozorientation', window) || isEventSupported('devicemotion', window)) {
+ if (window.DeviceOrientationEvent) {
+ window.addEventListener("deviceorientation", function () {
+ result.innerHTML = "Alpha: " + event.alpha;
+ result.innerHTML = result.innerHTML + "Beta: " + event.beta;
+ result.innerHTML = result.innerHTML + "Gamma: " + event.gamma;
+ }, true);
+ } else if (window.DeviceMotionEvent) {
+ window.addEventListener('devicemotion', function () {
+ tilt([event.acceleration.x * 2, event.acceleration.y * 2]);
+ result.innerHTML = "acceleration.x: " + event.acceleration.x;
+ result.innerHTML = result.innerHTML + "acceleration.y: " + event.acceleration.y;
+ result.innerHTML = result.innerHTML + "acceleration.z: " + event.acceleration.z;
+ result.innerHTML = result.innerHTML + "accelerationIncludingGravity.x: " + event.accelerationIncludingGravity.x;
+ result.innerHTML = result.innerHTML + "accelerationIncludingGravity.y: " + event.accelerationIncludingGravity.y;
+ result.innerHTML = result.innerHTML + "accelerationIncludingGravity.z: " + event.accelerationIncludingGravity.z;
+ result.innerHTML = result.innerHTML + "rotationRate.alpha: " + event.rotationRate.alpha;
+ result.innerHTML = result.innerHTML + "rotationRate.beta: " + event.rotationRate.beta;
+ result.innerHTML = result.innerHTML + "rotationRate.gamm: " + event.rotationRate.gamma;
+ }, true);
+ } else {
+ window.addEventListener("MozOrientation", function () {
+ result.innerHTML = "orientation.x: " + orientation.x;
+ result.innerHTML = result.innerHTML + "orientation.y: " + orientation.y;
+ result.innerHTML = result.innerHTML + "orientation.z: " + orientation.z;
+ }, true);
+ }
+ } else {
+ alert("Unfortunately, your brower doesn't support the orientation usage");
+ }
+
+ }
+ </script>
+</head>
+<body onload="init()">
+<h1 id="title">Accelerometer</h1>
+
+<p id="shortdesc">
+ The goal of this script is to demonstrate the usage of accelerometer
+</p>
+
+<div id="result">
+
+</div>
+</body>
+</html>
More information about the Commits
mailing list