orientation.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <!DOCTYPE HTML>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
  6. <meta name="HandheldFriendly" content="true">
  7. <meta name="MobileOptimized" content="320">
  8. <title>Orientation Document</title>
  9. <link rel="stylesheet" type="text/css" href="res/doc.css" charset="utf-8">
  10. <link rel="stylesheet" type="text/css" href="res/prettify.sons.css" charset="utf-8">
  11. <script type="text/javascript" src="res/doc.js" charset="utf-8"></script><script type="text/javascript" src="res/prettify.js" charset="utf-8"></script>
  12. </head>
  13. <body><div id="content" class="content">
  14. <h1><a name="plus.orientation">orientation</a></h1>
  15. <p>Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。</p>
  16. <h2>方法:</h2>
  17. <ul>
  18. <li>
  19. <a href="#plus.orientation.getCurrentOrientation">getCurrentOrientation</a>: 获取当前设备的方向信息,包括alpha、beta、gamma三个方向信息</li>
  20. <li>
  21. <a href="#plus.orientation.watchOrientation">watchOrientation</a>: 监听设备方向信息的变化</li>
  22. <li>
  23. <a href="#plus.orientation.clearWatch">clearWatch</a>: 关闭监听设备方向信息</li>
  24. </ul>
  25. <h2>对象:</h2>
  26. <ul>
  27. <li>
  28. <a href="#plus.orientation.OrientationOption">OrientationOption</a>: JSON对象,监听设备方向感应器参数</li>
  29. <li>
  30. <a href="#plus.orientation.Rotation">Rotation</a>: JSON对象,设备方向信息数据</li>
  31. </ul>
  32. <h2>回调方法:</h2>
  33. <ul>
  34. <li>
  35. <a href="#plus.orientation.OrientationSuccessCallback">OrientationSuccessCallback</a>: 获取设备方向信息成功的回调函数</li>
  36. <li>
  37. <a href="#plus.orientation.OrientationErrorCallback">OrientationErrorCallback</a>: 获取设备方向信息失败的回调函数</li>
  38. </ul>
  39. <h2>权限:</h2>
  40. <p>5+功能模块(permissions)</p>
  41. <pre class="prettyprint linenums">
  42. {
  43. // ...
  44. "permissions":{
  45. // ...
  46. "Orientation": {
  47. "description": "方向传感器"
  48. }
  49. }
  50. }
  51. </pre>
  52. <h1><a name="plus.orientation.OrientationOption">OrientationOption</a></h1>
  53. <p>JSON对象,监听设备方向感应器参数</p>
  54. <h2>属性:</h2>
  55. <ul><li>frequency: <em>(<font class="type">Number</font>
  56. 类型
  57. )</em>更新方向信息的时间间隔<br><p>数值类型,单位为ms,默认值为500ms。</p>
  58. </li></ul>
  59. <h1><a name="plus.orientation.Rotation">Rotation</a></h1>
  60. <p>JSON对象,设备方向信息数据</p>
  61. <pre class="prettyprint linenums">
  62. interface Rotation {
  63. readonly attribute float alpha;
  64. readonly attribute float beta;
  65. readonly attribute float gamma;
  66. readonly attribute float magneticHeading;
  67. readonly attribute float trueHeading;
  68. readonly attribute float headingAccuracy;
  69. }
  70. </pre>
  71. <h2>属性:</h2>
  72. <ul>
  73. <li>alpha: <em>(<font class="type">float</font>
  74. 类型
  75. )</em>以z方向为轴心的旋转角度<br><p>浮点数类型,只读属性,取值范围为0到360(不等于360)。</p>
  76. </li>
  77. <li>beta: <em>(<font class="type">float</font>
  78. 类型
  79. )</em>以x方向为轴心的旋转角度<br><p>浮点数类型,只读属性,取值范围为-180到180(不等于180)。</p>
  80. </li>
  81. <li>gamma: <em>(<font class="type">float</font>
  82. 类型
  83. )</em>以y方向为轴心的旋转角度<br><p>浮点数类型,只读属性,取值范围为-180到180(不等于180)。</p>
  84. </li>
  85. <li>magneticHeading: <em>(<font class="type">float</font>
  86. 类型
  87. )</em>设备方向与地球磁场北极方向的角度<br><p>浮点数类型,只读属性,取值范围为0到360(不等于360)。</p>
  88. </li>
  89. <li>trueHeading: <em>(<font class="type">float</font>
  90. 类型
  91. )</em>设备方向与地球真实北极方向的角度<br><p>浮点数类型,只读属性,取值范围为0到360(不等于360)。</p>
  92. </li>
  93. <li>headingAccuracy: <em>(<font class="type">float</font>
  94. 类型
  95. )</em>设备方向值的误差值<br><p>浮点数类型,只读属性,取值范围为0到360(不等于360)。</p>
  96. </li>
  97. </ul>
  98. <h1><a name="plus.orientation.OrientationSuccessCallback">OrientationSuccessCallback</a></h1>
  99. <p>获取设备方向信息成功的回调函数</p>
  100. <pre class="prettyprint linenums">
  101. void onSuccess( rotation ){
  102. // Get orientation success code.
  103. }
  104. </pre>
  105. <h2>参数:</h2>
  106. <ul><li>rotation:
  107. <em>(
  108. <font class="type">DOMString</font>
  109. )
  110. 必选 </em>设备的方向信息Rotation<br>
  111. </li></ul>
  112. <h2>返回值:</h2>
  113. <font class="type">void</font>
  114. : 无<h1><a name="plus.orientation.OrientationErrorCallback">OrientationErrorCallback</a></h1>
  115. <p>获取设备方向信息失败的回调函数</p>
  116. <pre class="prettyprint linenums">
  117. void onError( error ) {
  118. // Get orientation error code.
  119. }
  120. </pre>
  121. <h2>参数:</h2>
  122. <ul><li>error:
  123. <em>(
  124. <font class="type">DOMException</font>
  125. )
  126. 必选 </em>失败信息<br>
  127. </li></ul>
  128. <h2>返回值:</h2>
  129. <font class="type">void</font>
  130. : 无<br><br>
  131. </div></body>
  132. </html>