Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus. ...
<div id="article_content" class="article_content clearfix"><link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/kdoc_html_views-1a98987dfd.css">
<link rel="stylesheet" href="https://csdnimg.cn/release/blogv2/dist/mdeditor/css/editerView/ck_htmledit_views-6e43165c0a.css">
<div id="content_views" class="htmledit_views">
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">Orientation模块管理设备的方向信息,包括alpha、beta、gamma三个方向信息,通过plus.orientation可获取设备方向管理对象。</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">方法:</span></strong></span></h2>
<ul><li><ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.getCurrentOrientation">getCurrentOrientation</a>: 获取当前设备的方向信息,包括alpha、beta、gamma三个方向信息</li><li><ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.watchOrientation">watchOrientation</a>: 监听设备方向信息的变化</li><li><ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.clearWatch">clearWatch</a>: 关闭监听设备方向信息</li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">对象:</span></strong></span></h2>
<ul><li><ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.OrientationOption">OrientationOption</a>: JSON对象,监听设备方向感应器参数</li><li><ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.Rotation">Rotation</a>: JSON对象,设备方向信息数据</li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">回调方法:</span></strong></span></h2>
<ul><li><ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.OrientationSuccessCallback">OrientationSuccessCallback</a>: 获取设备方向信息成功的回调函数</li><li><ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.OrientationErrorCallback">OrientationErrorCallback</a>: 获取设备方向信息失败的回调函数</li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">权限:</span></strong></span></h2>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">5+功能模块(permissions)</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#ffffff">{</span>
<span style="color:#87ceeb">// ...</span>
<span style="color:#ffa0a0">"permissions"</span><span style="color:#ffffff">:{</span>
<span style="color:#87ceeb">// ...</span>
<span style="color:#ffa0a0">"Orientation"</span><span style="color:#ffffff">:</span> <span style="color:#ffffff">{</span>
<span style="color:#ffa0a0">"description"</span><span style="color:#ffffff">:</span> <span style="color:#ffa0a0">"方向传感器"</span>
<span style="color:#ffffff">}</span>
<span style="color:#ffffff">}</span>
<span style="color:#ffffff">}</span>
</code></span></span></code></pre>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_7-->getCurrentOrientation</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">获取当前设备的方向信息,包括alpha、beta、gamma三个方向信息</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">orientation</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getCurrentOrientation</span><span style="color:#ffffff">(</span><span style="color:#ffffff"> successCB</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> errorCB </span><span style="color:#ffffff">);</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">说明:</span></strong></span></h2>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。 方向信息可通过successCB回调函数返回。方向信息获取失败则调用回调函数errorCB</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">参数:</span></strong></span></h2>
<ul><li>successCB: <em>( <ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.OrientationSuccessCallback">OrientationSuccessCallback</a> ) 必选 </em>获取设备方向信息成功回调函数 <p style="margin-left:0;"></p> </li><li>errorCB: <em>( <ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.OrientationErrorCallback">OrientationErrorCallback</a> ) 可选 </em>获取设备方向信息失败回调函数 <p style="margin-left:0;"></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">返回值:</span></strong></span></h2>
<p>void<span style="color:#474747;"><span style="background-color:#f6f4f2;"> : 无</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">平台支持:</span></strong></span></h2>
<ul><li>Android - 2.2+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">示例:</span></strong></span></h2>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#cccccc"><!DOCTYPE html></span>
<span style="color:#f0e68c"><strong><html></strong></span>
<span style="color:#f0e68c"><strong><head></strong></span>
<span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span>
<span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Orientation Example</span><span style="color:#f0e68c"><strong></title></strong></span>
<span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span>
<span style="color:#87ceeb">// 扩展API加载完毕后调用onPlusReady回调函数 </span><span style="color:#ffffff">
document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span> <span style="color:#ffa0a0">"plusready"</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> onPlusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span> <span style="color:#ffffff">);</span>
<span style="color:#87ceeb">// 扩展API加载完毕,现在可以正常调用扩展API</span>
<span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> onPlusReady</span><span style="color:#ffffff">()</span> <span style="color:#ffffff">{</span><span style="color:#ffffff">
plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">orientation</span><span style="color:#ffffff">.</span><span style="color:#ffffff">getCurrentOrientation</span><span style="color:#ffffff">(</span> <span style="color:#f0e68c"><strong>function</strong></span> <span style="color:#ffffff">(</span><span style="color:#ffffff"> o </span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff">
alert</span><span style="color:#ffffff">(</span> <span style="color:#ffa0a0">"Orientation\nAlpha:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alpha </span><span style="color:#ffffff">+</span> <span style="color:#ffa0a0">"\nBeta:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">beta </span><span style="color:#ffffff">+</span> <span style="color:#ffa0a0">"\nGamma:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">gamma </span><span style="color:#ffffff">);</span>
<span style="color:#ffffff">}</span> <span style="color:#ffffff">);</span>
<span style="color:#ffffff">}</span>
<span style="color:#f0e68c"><strong></script></strong></span>
<span style="color:#f0e68c"><strong></head></strong></span>
<span style="color:#f0e68c"><strong><body></strong></span><span style="color:#ffffff">
Orientation
</span><span style="color:#f0e68c"><strong></body></strong></span>
<span style="color:#f0e68c"><strong></html></strong></span>
</code></span></span></code></pre>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><ahref="https://uniapp.dcloud.io/use-html5plus">uni-app使用plus注意事项</a></span></span></p>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_11-->watchOrientation</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">监听设备方向信息的变化</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#98fb98">Number</span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">orientation</span><span style="color:#ffffff">.</span><span style="color:#ffffff">watchOrientation</span><span style="color:#ffffff">(</span><span style="color:#ffffff"> successCB</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> errorCB</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> option </span><span style="color:#ffffff">);</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">说明:</span></strong></span></h2>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">方向信息是设备相对于水平初始方向分别以z、x、y轴为轴心旋转的角度,对应值为alpha、beta、gamma三个方向的信息。watchOrientation每隔固定时间就获取一次设备的方向信息,通过successCB回调函数返回。可通过option的frequency参数设定获取设备方向信息的时间间隔。方向信息获取失败则调用回调函数errorCB。</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">参数:</span></strong></span></h2>
<ul><li>successCB: <em>( <ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.OrientationSuccessCallback">OrientationSuccessCallback</a> ) 必选</em> <p style="margin-left:0;"><span style="color:#474747;">获取设备方向信息成功回调函数</span></p> </li><li>errorCB: <em>( <ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.OrientationErrorCallback">OrientationErrorCallback</a> ) 可选</em> <p style="margin-left:0;"><span style="color:#474747;">获取设备方向信息失败回调函数</span></p> </li><li>option: <em>( <ahref="https://blog.csdn.net/qq_40575646/article/details/122836962#plus.orientation.OrientationOption">OrientationOption</a> ) 可选</em> <p style="margin-left:0;"><span style="color:#474747;">监听设备方向信息的参数,如更新数据的频率等</span></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">返回值:</span></strong></span></h2>
<p>Number<span style="color:#474747;"><span style="background-color:#f6f4f2;"> : 用于标识方向信息监听器,可通过clearWatch方法取消监听。</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">平台支持:</span></strong></span></h2>
<ul><li>Android - 2.2+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">示例:</span></strong></span></h2>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#cccccc"><!DOCTYPE html></span>
<span style="color:#f0e68c"><strong><html></strong></span>
<span style="color:#f0e68c"><strong><head></strong></span>
<span style="color:#f0e68c"><strong><meta</strong></span> <span style="color:#bdb76b"><strong>charset</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"utf-8"</span><span style="color:#f0e68c"><strong>></strong></span>
<span style="color:#f0e68c"><strong><title></strong></span><span style="color:#ffffff">Orientation Example</span><span style="color:#f0e68c"><strong></title></strong></span>
<span style="color:#f0e68c"><strong><script</strong></span> <span style="color:#bdb76b"><strong>type</strong></span><span style="color:#ffffff">=</span><span style="color:#ffa0a0">"text/javascript"</span><span style="color:#f0e68c"><strong>></strong></span>
<span style="color:#87ceeb">// 扩展API加载完毕后调用onPlusReady回调函数 </span><span style="color:#ffffff">
document</span><span style="color:#ffffff">.</span><span style="color:#ffffff">addEventListener</span><span style="color:#ffffff">(</span> <span style="color:#ffa0a0">"plusready"</span><span style="color:#ffffff">,</span><span style="color:#ffffff"> onPlusReady</span><span style="color:#ffffff">,</span> <span style="color:#f0e68c"><strong>false</strong></span> <span style="color:#ffffff">);</span>
<span style="color:#87ceeb">// 扩展API加载完毕,现在可以正常调用扩展API</span>
<span style="color:#f0e68c"><strong>function</strong></span><span style="color:#ffffff"> onPlusReady</span><span style="color:#ffffff">()</span> <span style="color:#ffffff">{</span><span style="color:#ffffff">
plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">orientation</span><span style="color:#ffffff">.</span><span style="color:#ffffff">watchOrientation</span><span style="color:#ffffff">(</span> <span style="color:#f0e68c"><strong>function</strong></span> <span style="color:#ffffff">(</span><span style="color:#ffffff"> o </span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff">
alert</span><span style="color:#ffffff">(</span> <span style="color:#ffa0a0">"Orientation\nAlpha:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">alpha </span><span style="color:#ffffff">+</span> <span style="color:#ffa0a0">"\nBeta:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">beta </span><span style="color:#ffffff">+</span> <span style="color:#ffa0a0">"\nGamma:"</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> o</span><span style="color:#ffffff">.</span><span style="color:#ffffff">gamma </span><span style="color:#ffffff">);</span>
<span style="color:#ffffff">},</span> <span style="color:#f0e68c"><strong>function</strong></span> <span style="color:#ffffff">(</span><span style="color:#ffffff"> e </span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span><span style="color:#ffffff">
alert</span><span style="color:#ffffff">(</span> <span style="color:#ffa0a0">"Orientation error: "</span> <span style="color:#ffffff">+</span><span style="color:#ffffff"> e</span><span style="color:#ffffff">.</span><span style="color:#ffffff">message </span><span style="color:#ffffff">);</span>
<span style="color:#ffffff">}</span> <span style="color:#ffffff">);</span>
<span style="color:#ffffff">}</span>
<span style="color:#f0e68c"><strong></script></strong></span>
<span style="color:#f0e68c"><strong></head></strong></span>
<span style="color:#f0e68c"><strong><body></strong></span><span style="color:#ffffff">
Orientation watch
</span><span style="color:#f0e68c"><strong></body></strong></span>
<span style="color:#f0e68c"><strong></html></strong></span>
</code></span></span></code></pre>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><ahref="https://uniapp.dcloud.io/use-html5plus">uni-app使用plus注意事项</a></span></span></p>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_16-->clearWatch</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">关闭监听设备方向信息</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> plus</span><span style="color:#ffffff">.</span><span style="color:#ffffff">orientation</span><span style="color:#ffffff">.</span><span style="color:#ffffff">clearWatch</span><span style="color:#ffffff">(</span><span style="color:#ffffff"> watchId </span><span style="color:#ffffff">);</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">参数:</span></strong></span></h2>
<ul><li>watchId: <em>( Number ) 必选</em> <p style="margin-left:0;"><span style="color:#474747;">需要取消的方向监听器标识,调用watchOrientation方法的返回值。</span></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">返回值:</span></strong></span></h2>
<p>void<span style="color:#474747;"><span style="background-color:#f6f4f2;"> : 无</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">平台支持:</span></strong></span></h2>
<ul><li>Android - 2.2+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">支持</span></p> </li></ul>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_17-->OrientationOption</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">JSON对象,监听设备方向感应器参数</span></span></p>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">属性:</span></strong></span></h2>
<ul><li>frequency: <em>(Number 类型 )</em>更新方向信息的时间间隔 <p style="margin-left:0;"><span style="color:#474747;">数值类型,单位为ms,默认值为500ms。</span></p> </li></ul>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_18-->Rotation</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">JSON对象,设备方向信息数据</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#f0e68c"><strong>interface</strong></span> <span style="color:#98fb98">Rotation</span> <span style="color:#ffffff">{</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> alpha</span><span style="color:#ffffff">;</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> beta</span><span style="color:#ffffff">;</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> gamma</span><span style="color:#ffffff">;</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> magneticHeading</span><span style="color:#ffffff">;</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> trueHeading</span><span style="color:#ffffff">;</span>
<span style="color:#f0e68c"><strong>readonly</strong></span><span style="color:#ffffff"> attribute </span><span style="color:#f0e68c"><strong>float</strong></span><span style="color:#ffffff"> headingAccuracy</span><span style="color:#ffffff">;</span>
<span style="color:#ffffff">}</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">属性:</span></strong></span></h2>
<ul><li>alpha: <em>(float 类型 )</em>以z方向为轴心的旋转角度 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为0到360(不等于360)。</span></p> </li><li>beta: <em>(float 类型 )</em>以x方向为轴心的旋转角度 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为-180到180(不等于180)。</span></p> </li><li>gamma: <em>(float 类型 )</em>以y方向为轴心的旋转角度 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为-180到180(不等于180)。</span></p> </li><li>magneticHeading: <em>(float 类型 )</em>设备方向与地球磁场北极方向的角度 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为0到360(不等于360)。</span></p> <h3 style="margin-left:0;">平台支持</h3>
<ul style="margin-left:2em;"><li>Android - 2.2+ (支持)</li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">iTouch、iPad设备不支持</span></p> </li></ul></li><li>trueHeading: <em>(float 类型 )</em>设备方向与地球真实北极方向的角度 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为0到360(不等于360)。</span></p> <h3 style="margin-left:0;">平台支持</h3>
<ul style="margin-left:2em;"><li>Android - 2.2+ (支持)</li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">iTouch、iPad设备不支持</span></p> </li></ul></li><li>headingAccuracy: <em>(float 类型 )</em>设备方向值的误差值 <p style="margin-left:0;"><span style="color:#474747;">浮点数类型,只读属性,取值范围为0到360(不等于360)。</span></p> <h3 style="margin-left:0;">平台支持</h3>
<ul style="margin-left:2em;"><li>Android - 2.2+ (支持)</li><li>iOS - 4.3+ (支持) : <p style="margin-left:0;"><span style="color:#474747;">iTouch、iPad设备不支持</span></p> </li></ul></li></ul>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_19-->OrientationSuccessCallback</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">获取设备方向信息成功的回调函数</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> onSuccess</span><span style="color:#ffffff">(</span><span style="color:#ffffff"> rotation </span><span style="color:#ffffff">){</span>
<span style="color:#87ceeb">// Get orientation success code.</span>
<span style="color:#ffffff">}</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">参数:</span></strong></span></h2>
<ul><li>rotation: <em>( <ahref="https://www.html5plus.org/doc/zh_cn/orientation.html#plus.orientation.Rotation">Rotation</a> ) 必选 </em>设备的方向信息Rotation <p style="margin-left:0;"></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">返回值:</span></strong></span></h2>
<p>void<span style="color:#474747;"><span style="background-color:#f6f4f2;"> : 无</span></span></p>
<h1 style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;"><!--LINK#0_21-->OrientationErrorCallback</span></span></h1>
<p style="margin-left:0;"><span style="color:#474747;"><span style="background-color:#f6f4f2;">获取设备方向信息失败的回调函数</span></span></p>
<pre class="has" style="margin-left:0;"><code class="language-prettyprint"><span style="background-color:#333333"><span style="color:#474747"><code>
<span style="color:#f0e68c"><strong>void</strong></span><span style="color:#ffffff"> onError</span><span style="color:#ffffff">(</span><span style="color:#ffffff"> error </span><span style="color:#ffffff">)</span> <span style="color:#ffffff">{</span>
<span style="color:#87ceeb">// Get orientation error code. </span>
<span style="color:#ffffff">}</span>
</code></span></span></code></pre>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">参数:</span></strong></span></h2>
<ul><li>error: <em>( Exception ) 必选 </em>失败信息 <p style="margin-left:0;"></p> </li></ul>
<h2 style="margin-left:.8em;"><span style="color:#f13a0e;"><strong><span style="background-color:#f6f4f2;">返回值:</span></strong></span></h2>
<p>void<span style="color:#474747;"><span style="background-color:#f6f4f2;"> : 无</span></span></p>
</div>
</div>
<div id="treeSkill"></div>
页:
[1]