compass(指南针)phonegap中文api(

compass(指南针)phonegap中文api(

ID:17653818

大小:87.00 KB

页数:8页

时间:2018-09-04

compass(指南针)phonegap中文api(_第1页
compass(指南针)phonegap中文api(_第2页
compass(指南针)phonegap中文api(_第3页
compass(指南针)phonegap中文api(_第4页
compass(指南针)phonegap中文api(_第5页
资源描述:

《compass(指南针)phonegap中文api(》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、Commpass(指南针)获得该设备的方向指向。方法·compass.getCurrentHeading·compass.watchHeading·compass.clearWatch参数·compassSuccess·compassError·compassOptionscompass.getCurrentHeading获取当前罗盘航向。navigator.compass.getCurrentHeading(compassSuccess,compassError,compassOptions);说明指南针是一种传感器,检测到的方向或标题,指出该设备。 它的措施

2、,从0到359.99度的标题。指南针返回标题使用 compassSuccess 回调函数。支持的平台·Android·iPhone简单的例子functiononSuccess(heading){  alert('Heading:'+heading);};functiononError(){  alert('onError!');};navigator.compass.getCurrentHeading(onSuccess,onError);完整的例子

3、ttp://www.w3.org/TR/html4/strict.dtd">   CompassExample      //WaitforPhoneGaptoload  //  functiononLoad(){    document.addEventListener("dev

4、iceready",onDeviceReady,false);  }  //PhoneGapisready  //  functiononDeviceReady(){    navigator.compass.getCurrentHeading(onSuccess,onError);  }  //onSuccess:Getthecurrentheading  //  functiononSuccess(heading){    alert('Heading:'+heading);  }  //onError:Failedtogettheheading  //  

5、functiononError(){    alert('onError!');  }      

Example

  

getCurrentHeading

 compass.watchHeading在定期间隔,获得指南针度标题。varwatchID=navigator.compass.watchHeading(compassSuccess,compassError,[compassOptions]);说明指南针是一种传感器,检测到的

6、方向或标题,指出该设备。 它的措施,从0到359.99度的标题。该 compass.watchHeading 获取设备的当前间隔在例行标题。 每次标题检索, headingSuccess 回调函数被执行。 通过指定的时间间隔以毫秒为单位 的频率 参数在 compassOptions 对象。返回的手表ID引用引用指南针手表的时间间隔。 这款手表ID可用于 compass.clearWatch 停止看指南针。支持的平台·Android·iPhone简单的例子functiononSuccess(heading){  varelement=document.getEle

7、mentById('heading');  element.innerHTML='Heading:'+heading;};functiononError(){  alert('onError!');};varoptions={frequency:3000}; //Updateevery3secondsvarwatchID=navigator.compass.watchHeading(onSuccess,onError,options);完整的例子

8、p://www.w3.o

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。