[OpenLayers-Commits] r11369 - in sandbox/sbrunner: . addins
addins/deviceorientation addins/deviceorientation/trunk
addins/deviceorientation/trunk/examples
addins/deviceorientation/trunk/lib
addins/deviceorientation/trunk/lib/OpenLayers
addins/deviceorientation/trunk/lib/OpenLayers/Control
addins/deviceorientation/trunk/theme
addins/deviceorientation/trunk/theme/default
commits-20090109 at openlayers.org
commits-20090109 at openlayers.org
Wed Feb 23 13:30:33 EST 2011
Author: fredj
Date: 2011-02-23 10:30:33 -0800 (Wed, 23 Feb 2011)
New Revision: 11369
Added:
sandbox/sbrunner/addins/
sandbox/sbrunner/addins/deviceorientation/
sandbox/sbrunner/addins/deviceorientation/trunk/
sandbox/sbrunner/addins/deviceorientation/trunk/examples/
sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.html
sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.js
sandbox/sbrunner/addins/deviceorientation/trunk/lib/
sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/
sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/Control/
sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/Control/DeviceOrientation.js
sandbox/sbrunner/addins/deviceorientation/trunk/theme/
sandbox/sbrunner/addins/deviceorientation/trunk/theme/default/
sandbox/sbrunner/addins/deviceorientation/trunk/theme/default/style.css
Log:
deviceorientation addins
Added: sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.html
===================================================================
--- sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.html (rev 0)
+++ sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.html 2011-02-23 18:30:33 UTC (rev 11369)
@@ -0,0 +1,19 @@
+<!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 Device Orientation</title>
+ <link rel="stylesheet" href="http://www.openlayers.org/dev/theme/default/style.css" type="text/css"/>
+ <link rel="stylesheet" href="http://www.openlayers.org/dev/examples/style.css" type="text/css"/>
+ <script type="text/javascript" src="../../../../openlayers/lib/OpenLayers.js"></script>
+
+ <link rel="stylesheet" href="../theme/default/style.css" type="text/css"/>
+ <script type="text/javascript" src="../lib/OpenLayers/Control/DeviceOrientation.js"></script>
+ <script type="text/javascript" src="orientation.js"></script>
+</head>
+<body onload="init()">
+ <h1>Device Orientation</h1>
+ <div id="map" class="smallmap"></div>
+</body>
+</html>
Added: sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.js
===================================================================
--- sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.js (rev 0)
+++ sandbox/sbrunner/addins/deviceorientation/trunk/examples/orientation.js 2011-02-23 18:30:33 UTC (rev 11369)
@@ -0,0 +1,27 @@
+var map, orientation;
+function init() {
+ map = new OpenLayers.Map('map', {
+ layers: [new OpenLayers.Layer.OSM()]
+ });
+ orientation = new OpenLayers.Control.DeviceOrientation();
+ map.addControl(orientation);
+ map.zoomToMaxExtent();
+}
+
+// function init() {
+// var logs = document.getElementById("logs");
+// orientation = new OpenLayers.Control.DeviceOrientation();
+// if (orientation.supported()) {
+// orientation.events.register("orientationchange", this, function(event) {
+// logs.innerHTML = "rotation: " + event.orientation;
+
+// var img = document.getElementById("orientation");
+// var value = "rotate(" + event.orientation + "deg)";
+// img.style.transform = value;
+// img.style.webkitTransform = value;
+// });
+// orientation.activate();
+// } else {
+// logs.innerHTML = "This device don't supports device orientation";
+// }
+// }
Added: sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/Control/DeviceOrientation.js
===================================================================
--- sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/Control/DeviceOrientation.js (rev 0)
+++ sandbox/sbrunner/addins/deviceorientation/trunk/lib/OpenLayers/Control/DeviceOrientation.js 2011-02-23 18:30:33 UTC (rev 11369)
@@ -0,0 +1,58 @@
+/* Copyright (c) 2006-2011 by OpenLayers Contributors (see authors.txt for
+ * full list of contributors). Published under the Clear BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/license.txt for the
+ * full text of the license. */
+
+/**
+ * @requires OpenLayers/Control.js
+ */
+
+/**
+ * Class: OpenLayers.Control.DeviceOrientation
+ * see: http://dev.w3.org/geo/api/spec-source-orientation.html
+ */
+OpenLayers.Control.DeviceOrientation = OpenLayers.Class(OpenLayers.Control, {
+
+ /**
+ * APIMethod: supported
+ *
+ * Returns:
+ * {Boolean} Whether or not the browser supports device orientation
+ */
+ supported: function() {
+ return !!(window.DeviceOrientationEvent);
+ },
+
+ /**
+ * Method: draw
+ *
+ * Returns:
+ * {DOMElement}
+ */
+ draw: function() {
+ OpenLayers.Control.prototype.draw.apply(this, arguments);
+ if (this.supported()) {
+ window.addEventListener("deviceorientation",
+ OpenLayers.Function.bind(this.updateOrientation, this), true);
+ } else {
+ OpenLayers.Element.addClass(this.div, "unsupported");
+ }
+ return this.div;
+ },
+
+ updateOrientation: function(event) {
+ var v = "rotate(" + event.alpha - window.orientation - 90 + "deg)";
+ this.div.style.transform = v;
+ this.div.style.webkitTransform = v;
+ },
+
+ destroy: function() {
+ window.removeEventListener("deviceorientation",
+ OpenLayers.Function.bind(this.updateOrientation, this), true);
+
+ OpenLayers.Control.prototype.destroy.apply(this, arguments);
+ },
+
+ CLASS_NAME: "OpenLayers.Control.DeviceOrientation"
+});
+
Added: sandbox/sbrunner/addins/deviceorientation/trunk/theme/default/style.css
===================================================================
--- sandbox/sbrunner/addins/deviceorientation/trunk/theme/default/style.css (rev 0)
+++ sandbox/sbrunner/addins/deviceorientation/trunk/theme/default/style.css 2011-02-23 18:30:33 UTC (rev 11369)
@@ -0,0 +1,7 @@
+.olControlDeviceOrientation {
+ right: 5px;
+ top: 5px;
+ width: 30px;
+ height: 30px;
+ border: 1px solid red;
+}
More information about the Commits
mailing list