1. <i id='CkqnS'><tr id='CkqnS'><dt id='CkqnS'><q id='CkqnS'><span id='CkqnS'><b id='CkqnS'><form id='CkqnS'><ins id='CkqnS'></ins><ul id='CkqnS'></ul><sub id='CkqnS'></sub></form><legend id='CkqnS'></legend><bdo id='CkqnS'><pre id='CkqnS'><center id='CkqnS'></center></pre></bdo></b><th id='CkqnS'></th></span></q></dt></tr></i><div id='CkqnS'><tfoot id='CkqnS'></tfoot><dl id='CkqnS'><fieldset id='CkqnS'></fieldset></dl></div>
        <legend id='CkqnS'><style id='CkqnS'><dir id='CkqnS'><q id='CkqnS'></q></dir></style></legend>
          <bdo id='CkqnS'></bdo><ul id='CkqnS'></ul>
      1. <tfoot id='CkqnS'></tfoot>

      2. <small id='CkqnS'></small><noframes id='CkqnS'>

        phonegap 地理位置总是在超时时失败

        时间:2023-09-02

            <tbody id='8xG9u'></tbody>

            <i id='8xG9u'><tr id='8xG9u'><dt id='8xG9u'><q id='8xG9u'><span id='8xG9u'><b id='8xG9u'><form id='8xG9u'><ins id='8xG9u'></ins><ul id='8xG9u'></ul><sub id='8xG9u'></sub></form><legend id='8xG9u'></legend><bdo id='8xG9u'><pre id='8xG9u'><center id='8xG9u'></center></pre></bdo></b><th id='8xG9u'></th></span></q></dt></tr></i><div id='8xG9u'><tfoot id='8xG9u'></tfoot><dl id='8xG9u'><fieldset id='8xG9u'></fieldset></dl></div>
          1. <tfoot id='8xG9u'></tfoot>

                  <bdo id='8xG9u'></bdo><ul id='8xG9u'></ul>

                  <legend id='8xG9u'><style id='8xG9u'><dir id='8xG9u'><q id='8xG9u'></q></dir></style></legend>

                  <small id='8xG9u'></small><noframes id='8xG9u'>

                  本文介绍了phonegap 地理位置总是在超时时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在我的应用程序中使用 sencha-touch 2.0 和 phonegap 2.0.0 来检索用户的位置.在我的本地主机上运行时,一切正常.但是,当将 .apk 加载到我的 android 15 api 设备(使用 eclipse 和 adt 插件)时,每次调用 getCurrentLocation 或 watchPosition 都不会返回...

                  I'm using sencha-touch 2.0 and phonegap 2.0.0 in my app to retrieve user's location. When runing on my locahost, everything works just fine. However, when loading the .apk to my android 15 api's device (using eclipse and the adt plugin), every call to getCurrentLocation or watchPosition never returns...

                  这是我的代码:

                  geoOn: function(){
                      var geoReady = navigator.geolocation || undefined;
                  
                      var onSuccess = function(position){
                              Top5.app.alert('Geolocation success '+String(position.coords.latitude) + ' ' + String(position.coords.longitude),'Geolocation');
                              var scope = Ext.getCmp('nestedList');
                              scope.updateDistance(position.coords);
                      };
                  
                      var onFailure = function(error){Top5.app.alert('Geolocation failed: '+String(error.code) + ' '+String(error.message),'Geolocation');};
                      if (geoReady) {
                          this.watchId = navigator.geolocation.watchPosition(onSuccess ,onFailure,{timeout:6000,maximumAge: 3000,enableHighAccuracy: true});    
                      }
                      else{
                          Ext.device.Geolocation.watchPosition({
                                   frequency: 3000, // Update every 3 seconds
                                   callback: function(position) {
                                          this.updateDistance(position.coords);
                                   },
                                   failure: function() {
                                     console.log('Geolocation Failure!');
                                   },
                                   scope:this
                          });
                      }
                   },
                   geoGet: function(){
                       var geoReady = navigator.geolocation || undefined;
                       if (geoReady) {
                  
                           var onSuccess = function(position){
                               Top5.app.alert('Geolocation successful!!!');
                               var scope = Ext.getCmp('nestedList');
                               scope.updateDistance(position.coords);          
                           };
                           var onFailure = function(error){Top5.app.alert('Geolocation failed: '+String(error.code) + ' '+String(error.message),'Geolocation');};
                           navigator.geolocation.getCurrentPosition(onSuccess,onFailure);
                       }
                       else{}
                   },
                   geoOff:function(){
                  
                       var geoReady = navigator.geolocation || undefined;
                       if (geoReady) {
                           navigator.geolocation.clearWatch(this.watchId);
                           this.watchId = null;
                       }
                       else{
                           Ext.device.Geolocation.clearWatch();
                       }
                  
                   },
                   updateDistance:function(coords){
                       Top5.app.alert('updateDist','');
                       var scope = Ext.getCmp('nestedList');
                       var lat = coords.latitude,lon = coords.longitude;
                       var store = scope.getStore();
                       var i,record;
                       for(i = 0; i < store.data.all.length; i++)
                       {
                           record = store.data.all[i];
                           if(record.data.locationX){
                              record.set('distance',Top5.app.getDistance(record.data.locationX,record.data.locationY,lat,lon).toFixed(3));
                           }   
                       }
                  }
                  

                  更新:所以我走出了我的大楼,它奏效了......我需要更频繁地外出.
                  但是,当我禁用 gps 时,我认为 geoLocation 会使用 wifi 连接找到我的位置 - 但它失败了(我设置 enableHighAccuracy: false).这是为什么呢?

                  UPDATE: So I walked out of my building and it worked... I need to go outside more often.
                  However, when I'm disabling the gps, I thought geoLocation will find my location using wifi connection - but it failes (I'm setting enableHighAccuracy: false). Why is that?

                  更新:让我重新表述我的问题:navigator.geolocation.watchPosition 是否可以同时使用 GPS 信号和 wifi/g3 信号?如何仅使用互联网连接检测用户位置?目前,我的代码仅适用于 GPS,当禁用该选项或信号被阻止时,地理定位不起作用.

                  UPDATE: Let me rephrase my question: Does navigator.geolocation.watchPosition suppose to work both with GPS signal and wifi/g3 signals? How can I detect user location using internet connection only? currently, my code is working only with GPS, and when that option disabled or signal is blocked, geolocation isn't working.

                  推荐答案

                  我已经设法解决了.... 但是,我不知道实际解决了什么问题.我所做的只是改变我模型的一个结构.任何人都可以看到与地理位置的联系吗?

                  I've managed to work it out.... However , I have no idea what actually solved it. All I've done is to change one of my model's structure. Can anyone see the connection to geolocation?

                  这篇关于phonegap 地理位置总是在超时时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 Android 2.0+ 的 WebView 中使用 navigator.geolocation. 下一篇:如何找到两个地理点之间的距离?

                  相关文章

                  最新文章

                  <small id='zKN3M'></small><noframes id='zKN3M'>

                    <bdo id='zKN3M'></bdo><ul id='zKN3M'></ul>

                • <legend id='zKN3M'><style id='zKN3M'><dir id='zKN3M'><q id='zKN3M'></q></dir></style></legend>
                • <tfoot id='zKN3M'></tfoot>

                    <i id='zKN3M'><tr id='zKN3M'><dt id='zKN3M'><q id='zKN3M'><span id='zKN3M'><b id='zKN3M'><form id='zKN3M'><ins id='zKN3M'></ins><ul id='zKN3M'></ul><sub id='zKN3M'></sub></form><legend id='zKN3M'></legend><bdo id='zKN3M'><pre id='zKN3M'><center id='zKN3M'></center></pre></bdo></b><th id='zKN3M'></th></span></q></dt></tr></i><div id='zKN3M'><tfoot id='zKN3M'></tfoot><dl id='zKN3M'><fieldset id='zKN3M'></fieldset></dl></div>