Compass(指南针)phonegap中文API(_第1页
Compass(指南针)phonegap中文API(_第2页
Compass(指南针)phonegap中文API(_第3页
Compass(指南针)phonegap中文API(_第4页
Compass(指南针)phonegap中文API(_第5页
已阅读5页,还剩12页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Compass6旨南针)phonegap 中文 API(Commpass (指南针)获得该设备的方向指向。方法? compass.getCurrentHeading? compass.watchHeading? compass.clearWatch参数? compassSuccess? compassError? compassOptionscompass.getCurrentHeading获取当前罗盘航向。pass.getCurrentHeadin g(compassSuccess, compassError, compassOptions);说明它的措施,从0到指南针是一种传感器,检测到的

2、方向或标题,指出该设备。359.99度的标题。指南针返回标题使用compassSuccess 回调函数。支持的平台? Android? iPhone简单的例子function onSuccess(heading) alert( ;'Heading:'+ heading);charset ="utf-8”function onError() alert( ;Error!' );pass.getCurrentHeadin g(onSuccess, onError);完整的例子<!DOCTYPE HTML PUBLIC "-/W3C/DTDHTML

3、4.01/EN""/TR/html4/strict.dtd"> <html><head><title>Compass Example >script type ="text/javascript”src ="phonegap.js" ></script>script type ="text/javascriptcharset ="utf-8">/ Wait for PhoneGap to load/fu

4、nction onLoad() document.addEventListener("deviceready" , onDeviceReady, false ); / PhoneGap is ready/function onDeviceReady() pass.getCurren tHeading(onSuccess, onError);/ onSuccess: Get the current heading/function onSuccess(heading) alert( 'Heading: ' + heading); / onError: Fail

5、ed to get the heading/function onError() alert( 'onError!' );</script></head><body onload ="onLoad() "><h1> Example </h1><p> getCurrentHeading </p></body></html>compass.watchHeading在定期间隔,获得指南针度标题。var watchlD =pass.watchHeading(c

6、om passSuccess, compassError, compassOptions);说明指南针是一种传感器,检测到的方向或标题,指出该设备。它的措施,从0到359.99度的标题。该compass.watchHeading获取设备的当前间隔在例行标题。每次标题检索,headingSuccess回调函数被执行。通过指定的时间间隔以毫秒为单位的频率 参数在 compassOptions 对象。返回的手表ID引用引用指南针手表的时间问隔。这款手表ID可用于compass.clearWatch 停止看指南针。支持的平台? Android? iPhone简单的例子function onSucces

7、s(heading) var element =document.getElementById('heading' );element.innerHTML ='Heading:'+ heading;alert(Error!' );;var options= frequency: 3000 ;/Update every 3 secondsvar watchlD =pass.watchHeading(onS uccess, onError, options);完整的例子<!DOCTYPE HTML PUBLIC "-/W3C/DTDHTML

8、4.01/EN""/TR/html4/strict.dtd"><html><head><title>Compass Example </title>script type ="text/javascriptcharset ="utf-8”src ="phonegap.js" ></script>script type ="text/javascriptcharset ="utf-8">/

9、 The watch id references the current 'watchHeading'var watchlD = null/ Wait for PhoneGap to load/function onLoad() document.addEventListener("deviceready" , onDeviceReady, false ); / PhoneGap is ready/function onDeviceReady() startWatch();/ Start watching the compass/function start

10、Watch() / Update compass every 3 secondsvar options = frequency: 3000 ;watchID =pass.watchHeading(onS uccess, onError, options);/ Stop watching the compass/function stopWatch() if (watchID) pass.clearWatch(watchID);watchID =null ;/ onSuccess: Get the current heading/function onSuccess(heading) var e

11、lement =document.getElementById( 'heading' );element.innerHTML= 'Heading:'+ heading;/ onError: Failed to get the heading/function onError() alert( 'onError!' );</script></head><body onload ="onLoad() "><div id ="heading" >Waiting fo

12、rheading. </div>buttononclick =" startWatch(); " >StartWatching </button>buttononclick =" stopWatch(); " >StopWatching </button></body></html>compass.clearWatch不看指南针手表引用ID参数。pass.clearWatch(watchID);? watchlD : 返回的 ID compass.watchHeading 支持的平台

13、?机器人? iPhone简单的例子var watchlD =pass.watchHeading(onSuccess, onError, options);/ . later on .pass.clearWatch(watchID);完整的例子<!DOCTYPE HTML PUBLIC "-/W3C/DTDHTML 4.01/EN""/TR/html4/strict.dtd"><html><head><title> Compass Example >script type

14、 ="text/javascriptcharset ="utf-8"src ="phonegap.js" ></script>script type ="text/javascriptcharset ="utf-8">/ The watch id references the current 'watchHeading'var watchlD = null / Wait for PhoneGap to load/function onLoad() document.addEv

15、entListener("deviceready" , onDeviceReady, false ); / PhoneGap is ready/function onDeviceReady() startWatch();/ Start watching the compass/function startWatch() / Update compass every 3 secondsvar options = frequency:3000 ;watchlD =pass.watchHeading(onS uccess, onError, options);/ Stop wat

16、ching the compass /function stopWatch() if (watchID) pass.clear Watch(watchID);watchID =null/ onSuccess: Get the current heading /function onSuccess(heading) var element =document.getElementById( 'heading' );element.innerHTML= 'Heading:+ heading;/ onError: Failed to get the heading/funct

17、ion onError() alert( 'onError!' );</script></head><body onload ="onLoad() "><div id ="heading" >Waiting for heading. </div>buttononclick =" startWatch(); " >StartWatching </button>buttononclick =" stopWatch(); " >StopWatching </button></body></html>compassS

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论