Ext.util.Geolocation在sencha touch的应用程序中不起作用
在我的应用程序中,使用Ext.util.geology获取用户中的当前位置。它在电脑浏览器和手机浏览器中都能正常工作。但是当我为android创建.apk文件时,这个类就不起作用了 代码是Ext.util.Geolocation在sencha touch的应用程序中不起作用,geolocation,apk,Geolocation,Apk,在我的应用程序中,使用Ext.util.geology获取用户中的当前位置。它在电脑浏览器和手机浏览器中都能正常工作。但是当我为android创建.apk文件时,这个类就不起作用了 代码是 getCurrentlocation: function () { var geo = new Ext.util.Geolocation({ allowHighAccuracy : true, parseOptions: function() {
getCurrentlocation: function () {
var geo = new Ext.util.Geolocation({
allowHighAccuracy : true,
parseOptions: function() {
var timeout = this.getTimeout(),
ret = {
maximumAge: this.getMaximumAge(),
enableHighAccuracy: this.getAllowHighAccuracy()
};
if (timeout !== Infinity) {
ret.timeout = timeout;
}
return ret;
},
listeners : {
locationupdate : function(geo) {
Ext.Msg.alert('Error', geo.getLatitude());
Proximity.app.currLat = geo.getLatitude();
Proximity.app.currLong = geo.getLongitude();
localStorage.setItem('currLat',geo.getLatitude());
localStorage.setItem('currLong',geo.getLongitude());
},
locationerror : function(geo, timeout) {
if (timeout){
console.log('Timeout occurred.');
} else {
console.log('Error occurred.');
}
}
}
});
geo.updateLocation();
}
因此,我无法获取当前位置。如果有任何补充方法来获得坐标,请告诉我
谢谢。我知道有几种方法可以使用Sencha Touch定位设备:
navigator.geolocation.getCurrentPosition( function(position){
var lat = position.coords.latitude;
var lng = position.coords.longitude;
// HTML Geolocation error handling
}, function(error){
if (error.code == 1) {
// do something
} else if (error.code == 2){
// do something
} else if (error.code == 3){
// do something
}
},
// Low Accuracy
{enableHighAccuracy: false},
// Delivers new value after 75 seconds
{maximumAge: 75000}
); // anonym function
这是一篇关于HTML5地理定位的伟大著作
确保清单文件包含下一个字符串:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />