Mobile Device Features 2: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
Created page with "= Compass = * Certain devices have built in compasses * If they do, they call the ondeviceorientation() function when the compass reading changes. * An event object is pass..."
 
Line 1: Line 1:
= Compass =
= Compass =


* Certain devices have built in compasses
* Certain devices have a built in compasses


* If they do, they call the ondeviceorientation() function when the compass reading changes.
* If they do, they call the ondeviceorientation() function when the compass reading changes.

Revision as of 21:50, 10 December 2013

Compass

  • Certain devices have a built in compasses
  • If they do, they call the ondeviceorientation() function when the compass reading changes.
  • An event object is passed to the function with the compass reading in evt.webkitCompassHeading.
function window_ondeviceorientation(evt)
  TextBox1.value=evt.webkitCompassHeading
End function
<pre>

* The Compass sample uses this information to rotate an image of a compass.

* The webKitTransform function rotates an image efficiently.
<pre>
pos="0"

function window_ondeviceorientation(e)
  imgCompass.style.webkitTransform="rotate(" & pos & "deg)"
  pos = e.webkitCompassHeading
  imgCompass.style.webkitTransform="rotate(-" & pos & "deg)"
End function

Geolocation

Accelerometer