资源描述:
《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("dev4、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