-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compass example has limited browser support #144
Comments
I don't have that many different devices available. Do you? If so, would you mind testing this? function initCompass() {
const compass = new Kompas();
compass.watch();
compass.on('heading', function (heading) {
style.getImage().setRotation((Math.PI / 180) * heading);
});
}
locate.addEventListener('click', function () {
if (
window.DeviceOrientationEvent &&
typeof DeviceOrientationEvent.requestPermission === 'function'
) {
DeviceOrientationEvent.requestPermission()
.then(initCompass)
.catch(function (error) {
alert(`ERROR: ${error.message}`);
});
} else {
initCompass();
}
}); |
That is almost the method I used to get it working on Android with Chrome - although I put the Your proposed update certainly works with Chrome 99 Android 12 and also Chrome 81 Android 4.4 My application was using EPSG:27700. At the extremities there is a noticeable different between true and grid north and additional calculation is needed to align the compass correctly
|
The compass example depends on the
requestPermission
method which currently has limited browser support. On other browsers/devices either no extra permissions are needed or a request is triggered bywindow.addEventListener('deviceorientation')
. A more generic solution which maintains the existing structure might look likeThe text was updated successfully, but these errors were encountered: