首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >appMobi watchPosition getCurrentPosition失败

appMobi watchPosition getCurrentPosition失败
EN

Stack Overflow用户
提问于 2012-07-15 08:44:46
回答 1查看 472关注 0票数 0

appMobi watchPosition和getCurrentPosition失败了,我的小GPS图标出现并继续进行,但是从appmobi站点复制和粘贴它们的例子,我至少应该得到一个警告,如果不是,那么调试器的控制台出现错误,而我没有收到任何警告。

代码语言:javascript
复制
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

好的,再次更新

修正了最后一个问题,但是这个问题让我很为难,好像它跑了两次是为了现在停下来,我需要它只运行一次。我怎么能拿到呢?

EN

回答 1

Stack Overflow用户

发布于 2013-01-29 01:10:22

放一个旗子只运行一次。

代码语言:javascript
复制
    ...lat=0;
var suc = function(p){
    if ((p.coords.latitude != undefined)&&(lat==0))
    {
            console.log(p.coords.latitude);
            lat=p.coords.latitude;

..。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11490605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档