ios – Phonegap,Cordova watchposition火力每1秒成功一次

ios – Phonegap,Cordova watchposition火力每1秒成功一次,第1张

概述平台:iOS6 / OSx Lion. 我试图解决Phonegap / Cordova使用navigator.geolocation.watchPosition的方式. 文档说,选项“maximumAge”是要求系统检索位置的选项. 所以有这些选择: { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true } 我认为位置请求会每3秒触 平台:iOS6 / OSx lion.

我试图解决Phonegap / Cordova使用navigator.geolocation.watchposition的方式.

文档说,选项“maximumAge”是要求系统检索位置的选项.

所以有这些选择:

{ maximumAge: 3000,timeout: 5000,enableHighAccuracy: true }

我认为位置请求会每3秒触发一次?

无论什么样的最大值,我都会每1秒钟取一次成功

有人可以解释一下吗?

谢谢再见

解决方法 我目前正在使用带有setInterval的getCurrentposition解决此问题.我不确定后果可能是什么,但这似乎给了我最大的控制权,似乎是跨平台最一致的方法.

// call this oncesetupWatch(3000);// sets up the interval at the specifIEd frequencyfunction setupWatch(freq) {    // global var here so it can be cleared on logout (or whenever).    activeWatch = setInterval(watchLocation,freq);}// this is what gets called on the interval.function watchLocation() {    var gcp = navigator.geolocation.getCurrentposition(            updateUserLoc,onLocationError,{                enableHighAccuracy: true            });    // console.log(gcp);}// do something with the resultsfunction updateUserLoc(position) {var location = {    lat : position.coords.latitude,lng : position.coords.longitude};console.log(location.lat);console.log(location.lng);}// stop watchingfunction logout() {    clearInterval(activeWatch);}
总结

以上是内存溢出为你收集整理的ios – Phonegap,Cordova watchposition火力每1秒成功一次全部内容,希望文章能够帮你解决ios – Phonegap,Cordova watchposition火力每1秒成功一次所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1068461.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存