I’m utilizing an ipad professional working 16.3.1 and an iphone Xs Max working 16.1.1.
I’m attempting to create an online web page that might want to entry the compass.
As it is a personal mission I’m not frightened about Android gadgets.
Right here is the take a look at code I’m utilizing:
<!DOCTYPE html>
<html>
<head>
<title>Compass Heading</title>
</head>
<physique>
<h1>Compass Heading: <span id="heading">not modified</span>°</h1>
<script>
// verify if the machine has a compass
if ('ondeviceorientation' in window && 'webkitCompassHeading' in occasion) {
// pay attention for modifications within the machine's orientation
window.addEventListener('deviceorientation', operate(occasion) {
//alert('occasion fired');
// get the compass heading in levels
var heading = occasion.webkitCompassHeading;
// replace the heading on the web page
doc.getElementById('heading').textContent = heading.toFixed(2);
});
} else {
alert('Sorry, your machine doesn't have a compass.');
}
</script>
</physique>
</html>
I don’t get the alert however I additionally don’t get any change within the textual content (not modified). I’ve tried placing an alert into the occasion listener and it’s not proven.
I’ve ensured that Compass is about to ‘inside app’ in Location Companies on each gadgets and the compass app works on each gadgets.
I’ve learn conflicting feedback on different posts, most fairly previous.
Can any person give me the most recent easiest resolution.