![](/img/trans.png)
[英]How to get geolocation working on appcelerator's titanium mobile application with android webview
[英]Appcelerator Geolocation not working on Android
以下Titanium示例代码适用于iPhone,但不适用于Android。 有人可以告诉我如何编写该代码,使其也可以在Android 2.3.3上运行吗? 如果我注释掉“ Ti.Geolocation.getCurrentPosition”及其结束标记,则不会显示该错误。
if (!_bounty.captured) {
var captureButton = Ti.UI.createButton({
title:L('capture'),
top:10,
height:30,
width:200
});
captureButton.addEventListener('click', function() {
if (Ti.Geolocation.locationServicesEnabled) {
Ti.Geolocation.accuracy = Ti.Geolocation.ACCURACY_BEST;
Ti.Geolocation.getCurrentPosition(function(e) { //*causes error on Android*
var lng = e.coords.longitude;
var lat = e.coords.latitude;
bh.db.bust(_bounty.id, lat, lng);
bh.net.bustFugitive(Ti.Platform.id, function(_data) {
Ti.UI.createAlertDialog({
message:_data.message
}).show();
//on android, give a bit of a delay before closing the window...
if (Ti.Platform.osname == 'android') {
setTimeout(function() {
win.close();
},2000);
}
else {
win.close();
}
});
});
}
else {
Ti.UI.createAlertDialog({
title:L('geo_error'),
message:L('geo_error_details')
}).show();
}
});
win.add(captureButton);
}
任何帮助表示赞赏。
您必须使用Google API SDK才能在Android上使用地理位置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.