The deviceorientationevent is the absolute value of obtaining the direction and obtaining the device at rest;
Devicemotionevent is the rate at which the device moves relative to the previous time
The device Locator API, which allows you to collect device orientation and mobile information. In addition, the API is used only on devices that have a gyroscope capability.
<title>DeviceOrientationEvent</title>
<meta charset= "UTF-8"/>
<body>
<p> around: <span id= "Alpha" >0</span>
</p>
<p> before and after: <span id= "Beta" >0</span>
</p>
<p> twist: <span id= "Gamma" >0</span>
</p>
<p> North Arrow Point: <span id= "heading" >0</span> degree </p>
<p> North Needle accuracy: <span id= "accuracy" >0</span> degree </p>
<p>x axis acceleration: <span id= "x" >0</span> meters per two square seconds </p>
<p>y axis acceleration: <span id= "y" >0</span> meters per two square seconds </p>
<p>z axis acceleration: <span id= "Z" >0</span> meters per two square seconds </p>
<p>x axis Acceleration (considering acceleration of gravity): <span id= "xg" >0</span> meters per two square seconds </p>
<p>y axis Acceleration (considering the acceleration of gravity): <span id= "YG" >0</span> meters per two square seconds </p>
<p>z axis Acceleration (considering acceleration of gravity): <span id= "ZG" >0</span> meters per two square seconds </p>
<p> rotation speed: <span id= "Ralpha" >0</span> degrees per second </p>
<p> before and after rotation speed: <span id= "Rbeta" >0</span> degrees per second </p>
<p> Twist Speed: <span id= "Rgamma" >0</span> degrees per second </p>
<p> last received notification interval: <span id= "Interval" >0</span> milliseconds </p>
<script type= "Text/javascript" >
function Orientationhandler (event) {
document.getElementById ("Alpha"). InnerHTML = Event.alpha;
document.getElementById ("beta"). InnerHTML = Event.beta;
document.getElementById ("Gamma"). InnerHTML = Event.gamma;
document.getElementById ("heading"). InnerHTML = event.webkitcompassheading;
document.getElementById ("accuracy"). InnerHTML = Event.webkitcompassaccuracy;
}
function Motionhandler (event) {
document.getElementById ("Interval"). InnerHTML = Event.interval;
var acc = event.acceleration;
document.getElementById ("x"). InnerHTML = acc.x;
document.getElementById ("Y"). InnerHTML = Acc.y;
document.getElementById ("Z"). InnerHTML = Acc.z;
var accgravity = event.accelerationincludinggravity;
document.getElementById ("xg"). InnerHTML = accgravity.x;
document.getElementById ("YG"). InnerHTML = ACCGRAVITY.Y;
document.getElementById ("ZG"). InnerHTML = accgravity.z;
var rotationrate = event.rotationrate;
document.getElementById ("Ralpha"). InnerHTML = Rotationrate.alpha;
document.getElementById ("Rbeta"). InnerHTML = Rotationrate.beta;
document.getElementById ("Rgamma"). InnerHTML = Rotationrate.gamma;
}
if (window. Devicemotionevent) {
Window.addeventlistener ("Devicemotion", Motionhandler, false);
} else {
Document.body.innerHTML = "What user agent u r using???";
}
if (window. Deviceorientationevent) {
Window.addeventlistener ("Deviceorientation", Orientationhandler, false);
} else {
Document.body.innerHTML = "What user agent u r using???";
};
</script>
</body>