forked from TommyTeaVee/ios_15_rce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
accelerometer.html
82 lines (78 loc) · 3.16 KB
/
accelerometer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="initial-scale=1,user-scalable=no, width=device-width, height=device-height, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>OpenLayers 2 Game: Bounce Ball</title>
<link rel="stylesheet" href="css/style1.css" type="text/css">
<link rel="stylesheet" href="css/style2.css" type="text/css">
<script src="js/OpenLayers.mobile.js"></script>
<style type="text/css">
html, body { height: 100%; }
#shortdesc { display: none; }
#tags { display: none; }
</style>
<script type="text/javascript">
var map, vlayer;
function adjustLocation(delta, feature) {
feature.geometry.move(delta.x, delta.y);
var me = map.maxExtent;
var rad = 6;
if (feature.geometry.x > (me.right - rad)) {
feature.geometry.x = me.right - rad;
} else if (feature.geometry.x < (me.left+rad)) {
feature.geometry.x = me.left+rad;
}
if (feature.geometry.y > (me.top-rad)) {
feature.geometry.y = me.top-rad;
} else if (feature.geometry.y < (me.bottom+rad)) {
feature.geometry.y = me.bottom+rad;
}
vlayer.drawFeature(feature);
}
function init() {
map = new OpenLayers.Map( 'map',
{
'maxExtent': new OpenLayers.Bounds(0, 0, document.getElementById("map").clientWidth, document.getElementById("map").clientHeight),
controls: [],
maxResolution: 'auto'}
);
var layer = new OpenLayers.Layer("",
{isBaseLayer: true} );
map.addLayer(layer);
map.zoomToMaxExtent();
vlayer = new OpenLayers.Layer.Vector();
var feature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(map.getCenter().lon, map.getCenter().lat));
vlayer.addFeatures(feature);
map.addLayer(vlayer);
if (window.DeviceMotionEvent) {
window.addEventListener('devicemotion', function (evt) {
var delta = null;
if (typeof(evt.accelerationIncludingGravity) != 'undefined') {
delta = {
'x': evt.accelerationIncludingGravity.x * 3,
'y': evt.accelerationIncludingGravity.y * 3,
'z': evt.accelerationIncludingGravity.z
}
}
adjustLocation(delta, feature);
}, true);
} else {
alert("This demo does not work on your browser.");
}
}
</script>
</head>
<body onload="init()">
<h1 id="title">Accelerometer Test</h1>
<div id="tags">
mobile, game
</div>
<div id="map" width="100%" height="100%" style="background-color: gray"></div>
<div id="docs">
<p><a href="index.html">back to diagnostics</a></p>
</div>
</body>
</html>