-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcompass.html
More file actions
37 lines (35 loc) · 879 Bytes
/
compass.html
File metadata and controls
37 lines (35 loc) · 879 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mappy</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body>
<p>
Value = <span id="target"></span>
</p>
<script>
var target = document.getElementById("target")
if (!window.DeviceOrientationEvent) {
target.innerHTML = "Not supported."
}
target.innerHTML = 'init'
window.addEventListener('deviceorientation', devOrientHandler, false)
function devOrientHandler(event) {
console.log(event)
target.innerHTML = event.alpha
if (event.webkitCompassHeading) {
alpha = event.webkitCompassHeading;
}
//non iOS
else {
alpha = event.alpha;
}
var locationIcon = myLocationMarker.get('icon');
locationIcon.rotation = 360 - alpha;
}
</script>
</body>
</html>