HTML
<button id = "getOrientation">GET ORIENTATION</button>
JAVASCRIPT
document.getElementById("getOrientation").addEventListener("click", getOrientation);
function getOrientation() {
navigator.compass.getCurrentHeading(compassSuccess, compassError);
function compassSuccess(heading) {
alert('Heading: ' + heading.magneticHeading);
setTimeout(function() {
navigator.compass.clearWatch(watchID);
}, 10000);
};
function compassError(error) {
alert('CompassError: ' + error.code);
};
}
dw
ReplyDeletehii
Delete