This isn't an issue, I found a fix, so if you want to add it for iPhone support it's good. By default on iPhone devices the compass access is not authorized, you can show this code to ensure the iPhone support will work after permission asked :
// Compass mode
else if (!map.compassBearing.enabled()) {
map.touchRotate.disable();
// map.compassBearing.enable(); // -- before
// new code added ---> start
if (DeviceOrientationEvent && typeof DeviceOrientationEvent.requestPermission === "function") {
DeviceOrientationEvent.requestPermission().then(function (permissionState) {
if (permissionState === "granted") {
map.compassBearing.enable();
}
});
} else {
map.compassBearing.enable();
}
// new code added <--- end
}
This isn't an issue, I found a fix, so if you want to add it for iPhone support it's good. By default on iPhone devices the compass access is not authorized, you can show this code to ensure the iPhone support will work after permission asked :