Skip to content

Commit

Permalink
Merge pull request #12 from danielgilbers/feature/rotation
Browse files Browse the repository at this point in the history
rotate map to compass
  • Loading branch information
danielgilbers authored Aug 27, 2024
2 parents 17cdf1d + d0118a3 commit 9d8b7d7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,3 +422,18 @@ const html5QrcodeScanner = new Html5QrcodeScanner(
{ fps: 10, qrbox: { width: 250, height: 250 } },
/* verbose= */ false)
html5QrcodeScanner.render(onScanSuccess, onScanFailure)

// Request permission for iOS 13+ devices
if (
DeviceMotionEvent &&
typeof DeviceMotionEvent.requestPermission === "function"
) {
DeviceMotionEvent.requestPermission();
}

window.addEventListener("deviceorientation", handleOrientation);

function handleOrientation(event) {
let orientation = event.webkitCompassHeading.toFixed(10)
map.setBearing(orientation)
}

0 comments on commit 9d8b7d7

Please sign in to comment.