2014-03-12 18 views
4

我已经创建了sencha touch应用程序,我想尝试使用下面的代码获取android设备的当前位置。如何使用sencha touch仅获得gps位置?

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 possition更新当前位置。 像Android的谷歌地图应用程序的GPS图标总是稳定的,我想在我的应用程序中喜欢。

回答

2

启动您的设备WI-FI,然后尝试加载您的应用程序。
因为它会帮我从gps获取当前位置。
我面临同样的问题,从GPS获取当前位置。
我也加了一个问题来解决这些问题See The Question

+1

感谢您帮助我解决问题。 –

2

添加频率参数在GeoLocation对象中。

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); 
    } 
    } 
} 
}); 

频率值以毫秒为单位,它是用来通过给定的时间来更新地理位置信息。

+1

我使用频率参数geolocaion我也给频率:1,但直到我的图标闪烁非常快。 –