gpt4 book ai didi

android - Titanium.Geolocation.getCurrentPosition() 没有给出输出

转载 作者:行者123 更新时间:2023-11-29 00:37:38 26 4
gpt4 key购买 nike

这是我在 Titanium Appcelerator 上的代码:

  function ApplicationWindow(title) {
var self = Ti.UI.createWindow({
title:title,
backgroundColor:'white'
});

var button = Ti.UI.createButton({
height:44,
width:200,
title:L('openWindow'),
top:200
});


self.add(button);

function getPosition() {
alert("In the Function");
Titanium.Geolocation.getCurrentPosition(function(e) {
Titanium.Geolocation.distanceFilter = 10;
Ti.Geolocation.preferredProvider = "gps";

if (e.error) {
Ti.UI.createAlertDialog({
title: L('geolocate_failure'),
message: e.error
}).show();
return;
}
var found = new Object();
locateIndicator.show();
found.longitude = e.coords.longitude;
found.latitude = e.coords.latitude;
found.altitude = e.coords.altitude;
found.heading = e.coords.heading;
found.accuracy = e.coords.accuracy;
found.speed = e.coords.speed;
found.timestamp = e.coords.timestamp;
found.altitudeAccuracy = e.coords.altitudeAccuracy;
return found
});
}

button.addEventListener('click', function() {
alert("button click");
getPosition();
});
return self;
};

module.exports = ApplicationWindow;

当我在 Android Emulator 中运行这段代码时,它会弹出一个消息“Location is currently unavailable”。这是否意味着直到我在手机上运行此代码(启用 GPS)它不会给我任何与 GPS 相关的输出?还是我的代码有问题?
谢谢。

最佳答案

如果你想在你的模拟器中运行地理位置服务,那么你必须在 ddms 中设置纬度和经度。

关于android - Titanium.Geolocation.getCurrentPosition() 没有给出输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11607429/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com