Skip to content

Commit

Permalink
try to fix compass permission
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgilbers committed Aug 27, 2024
1 parent b10d991 commit 9438c84
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,18 @@ const html5QrcodeScanner = new Html5QrcodeScanner(
/* verbose= */ false)
html5QrcodeScanner.render(onScanSuccess, onScanFailure)

// Request permission for iOS 13+ devices
if (
DeviceOrientationEvent &&
typeof DeviceOrientationEvent.requestPermission === 'function'
) {
DeviceOrientationEvent.requestPermission()
}

window.addEventListener('deviceorientation', handleOrientation)

function handleOrientation (event) {
const bias = 120 // rotation of png
const orientation = 360 - event.webkitCompassHeading
map.setBearing(orientation + bias)
}

// Request permission for iOS 13+ devices
if (
DeviceOrientationEvent &&
typeof DeviceOrientationEvent.requestPermission === 'function'
) {
DeviceOrientationEvent.requestPermission()
}

0 comments on commit 9438c84

Please sign in to comment.