appMobi watchPosition getCurrentPosition fail
appMobi watchPosition getCurrentPosition fail
appMobi watchPosition和getCurrentPosition失败,我的小GPS图标出现并继续,但从appMobi站点复制和粘贴(以它们的确切示例为例),我至少应该得到一个警告,如果没有,那么调试器控制台中的错误,我也没有得到。
var options = {timeout: 10000, maximumAge: 11000, enableHighAccuracy: true };
//This function is called on every iteration of the watch Position command that fails
var fail = function(){
alert("Geolocation failed. 'nPlease enable GPS in Settings.");
};
//This function is called on every iteration of the watchPosition command that is a success
var suc = function(p){
alert("Moved To: Latitude:" + p.coords.latitude + "Longitude: " + p.coords.longitude;
};
//This command starts watching the geolocation
var geolocationWatchTimer = AppMobi.geolocation.watchPosition(suc,fail,options);
//Call the stopGeolocation function to stop the geolocation watch
var stopGeolocation = function(){
AppMobi.geolocation.clearWatch(geolocationWatchTimer);
}
更新
好的,注意到即使使用这个例子,代码也有一定的漏洞。它缺少a)和a;所以有了这些,我现在得到了Uncaught TypeError: Cannot call method 'watchPosition' of undefined
好的,再次更新
修复了上一个问题,但这个问题让我很困惑,现在似乎它运行了2次是为了停止,我只需要它运行一次。我怎么能拿到?
只运行一次标志
...lat=0;
var suc = function(p){
if ((p.coords.latitude != undefined)&&(lat==0))
{
console.log(p.coords.latitude);
lat=p.coords.latitude;
相关文章:
- ExtJS 4 Object.prototype fail
- jquery post.fail,即使php成功
- Flickr api returns data fail() jquery
- jQuery $.getJSON Fail
- appMobi watchPosition getCurrentPosition fail
- jQuery deferred:在fail()回调中抛出并捕获异常
- JQuery / $.ajax /alert in .fail,但它成功了
- 在这种情况下,.fail() 或 .timeout() 更好吗?
- jQuery AJAX:成功时返回request.fail
- 如何区分 jQuery .fail()
- Deferred.pipe() 可以防止调用后续的 .done 和 .fail 吗?
- JQuery Promise:fail()在未等待Promise解析的情况下被调用
- 我的函数应该通过.fail()回调为Ajax请求返回什么
- jQuery Deferred - catch vs fail
- chrome.tabs.getCurrent() or tabs.query()
- Call ajax.fail() from ajax.success()
- Node.js”;auth fail”;当连接到MongoDB Replicaset时,3台服务器中只有2台在运行
- Aptana 3.0.8 .exe Fail
- 如何将一些指定的时间设置为ajax调用,这样如果请求正在花费时间检索数据,它应该来到FAIL块
- 代码镜像的详细模式(无silent-fail)