|
|
@ -9,7 +9,9 @@
|
|
|
|
<div class="arrow"></div>
|
|
|
|
<div class="arrow"></div>
|
|
|
|
<div class="compass-circle"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z"/></svg></div>
|
|
|
|
<div class="compass-circle"><svg viewBox="0 0 25 25" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd"><path class="st0" d="M13,2.6l6.2,7.5L20,9.5l-7.5-9L5,9.5l0.8,0.6L12,2.6v21.9h1C13,24.5,13,2.6,13,2.6z"/></svg></div>
|
|
|
|
<div class="my-point"></div>
|
|
|
|
<div class="my-point"></div>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button class="start-btn">Start compass</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- <h1 class="header" id="title">GEO</h1> -->
|
|
|
|
<!-- <h1 class="header" id="title">GEO</h1> -->
|
|
|
@ -341,12 +343,13 @@
|
|
|
|
navigator.userAgent.match(/AppleWebKit/);
|
|
|
|
navigator.userAgent.match(/AppleWebKit/);
|
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
function init() {
|
|
|
|
// startBtn.addEventListener("click", startCompass);
|
|
|
|
startBtn.addEventListener("click", startCompass);
|
|
|
|
navigator.geolocation.getCurrentPosition(locationHandler);
|
|
|
|
navigator.geolocation.getCurrentPosition(locationHandler);
|
|
|
|
|
|
|
|
|
|
|
|
if (!isIOS) {
|
|
|
|
if (!isIOS) {
|
|
|
|
window.addEventListener("deviceorientationabsolute", handler, true);
|
|
|
|
window.addEventListener("deviceorientationabsolute", handler, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function startCompass() {
|
|
|
|
function startCompass() {
|
|
|
@ -354,7 +357,6 @@
|
|
|
|
DeviceOrientationEvent.requestPermission()
|
|
|
|
DeviceOrientationEvent.requestPermission()
|
|
|
|
.then((response) => {
|
|
|
|
.then((response) => {
|
|
|
|
if (response === "granted") {
|
|
|
|
if (response === "granted") {
|
|
|
|
alert("granted")
|
|
|
|
|
|
|
|
window.addEventListener("deviceorientation", handler, true);
|
|
|
|
window.addEventListener("deviceorientation", handler, true);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
alert("has to be allowed!");
|
|
|
|
alert("has to be allowed!");
|
|
|
@ -366,7 +368,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
function handler(e) {
|
|
|
|
function handler(e) {
|
|
|
|
compass = e.webkitCompassHeading || Math.abs(e.alpha - 360);
|
|
|
|
compass = e.webkitCompassHeading || Math.abs(e.alpha - 360);
|
|
|
|
compassCircle.style.transform = `translate(-50%, -50%) rotate(${-compass}deg)`;
|
|
|
|
compassCircle.style.transform = `translate(-50%, -50%) rotate(${pointDegree-compass}deg)`;
|
|
|
|
|
|
|
|
|
|
|
|
// ±15 degree
|
|
|
|
// ±15 degree
|
|
|
|
|
|
|
|
|
|
|
@ -422,7 +424,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
init();
|
|
|
|
init();
|
|
|
|
startCompass();
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|