【问题标题】:How to get only gps location using sencha touch?如何使用 sencha touch 仅获取 gps 位置?
【发布时间】:2014-03-12 05:52:00
【问题描述】:

我已经创建了 sencha touch 应用程序,我想尝试使用以下代码获取 android 设备的当前位置。

Ext.create('Ext.util.Geolocation',  
autoUpdate: true,  
allowHighAccuracy: true,  
listeners: {  
locationupdate: function(geo) {  
    latitude=geo.position.coords.latitude;  
    longitude=geo.position.coords.longitude;  
    if(Global.currentUserPositionMarker)  
    {  
        latlng1=new google.maps.LatLng(latitude, longitude);  
        currentPosMarker.setPosition(latlng1);  
    }  
   }  
  }  
});  

在我的设备中,gps 图标会闪烁,但无法获取设备 gps 位置的当前位置。 它总是从我的网络提供商处获取当前位置。
我想经常从设备 gps 位置更新当前位置。 像 google map 应用程序一样,gps 图标总是稳定的,我想在我的应用程序中喜欢它。

【问题讨论】:

    标签: android gps sencha-touch-2


    【解决方案1】:

    启动您的设备 WI-FI,然后尝试加载您的应用。
    因为它可以让我从 gps 获取当前位置。
    我在从 gps 获取当前位置时遇到了同样的问题。
    我还添加了与这些问题相关的问题See The Question

    【讨论】:

      【解决方案2】:

      在 GeoLocation 对象中添加 Frequency 参数。

      Ext.create('Ext.util.Geolocation',  
      autoUpdate: true,
      frequency:1000,  
      allowHighAccuracy: true,  
      listeners: {  
      locationupdate: function(geo) {  
          latitude=geo.position.coords.latitude;  
          longitude=geo.position.coords.longitude;  
          if(Global.currentUserPositionMarker)  
          {  
              latlng1=new google.maps.LatLng(latitude, longitude);  
              currentPosMarker.setPosition(latlng1);  
          }  
         }  
       }  
      });
      

      频率值以毫秒为单位,用于在给定时间更新地理位置。

      【讨论】:

      • 我在 geolocaion 中使用频率参数,我也给出了频率:1,但直到我的图标快速闪烁。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-02
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多