gpt4 book ai didi

javascript - Titan 地理定位在 Android 模拟器中不起作用

转载 作者:行者123 更新时间:2023-11-28 02:31:06 25 4
gpt4 key购买 nike

我收到此错误:

[ERROR][GeolocationModule( 278)] (KrollRuntimeThread) [633,2564] Unable to get current position, location is null

我听从了其他人的建议,但没有任何运气。

有人能引导我走向正确的方向吗?我将非常感激。谢谢!

var win1 = Titanium.UI.createWindow({
title : 'map_landing',
backgroundColor : '#fff'
});

var win2 = Titanium.UI.createWindow({
title : 'hails_window',
backgroundColor : '#fff'
});

var win3 = Titanium.UI.createWindow({
title : 'cabs_window',
backgroundColor : '#fff'
});

User = {
location : {}
};

var hail_button = Titanium.UI.createButton({
title : 'Hail Cab',
top : 10,
width : 200,
height : 50
});

var find_button = Titanium.UI.createButton({
title : 'Find People',
bottom : 10,
width : 200,
height : 50
});

var options = {
accessKeyId : '',
secretAccessKey : ''
}

Ti.Geolocation.purpose = "Receive user location";

Titanium.Geolocation.getCurrentPosition(function(e) {
if (e.error) {
alert('HFL cannot get your current location');
return;
}

User.location.longitude = e.coords.longitude;
User.location.latitude = e.coords.latitude;
User.location.accuracy = e.coords.accuracy;
User.location.speed = e.coords.speed;
User.location.timestamp = e.coords.timestamp;

var mapview = Titanium.Map.createView({
mapType : Titanium.Map.STANDARD_TYPE,
region : {
latitude : User.location.latitude,
longitude : User.location.longitude,
latitudeDelta : 0.01,
longitudeDelta : 0.01
},
animate : true,
regionFit : true,
userLocation : true
});

win1.add(mapview);
win1.add(hail_button);
win1.add(find_button);
hail_button.addEventListener('click', function(e) {
alert('hello');
$.ajax('http://hail.pagodabox.com/add_hail', {
type : 'POST',
lat : User.location.latitude,
lang : User.location.longitude,
success : function(response) {
alert(response)
}
})
});

find_button.addEventListener('click', function(e) {

});
win1.open();
});

最佳答案

我花了一些时间才找到这个问题,但我想我已经找到了“修复”Android 模拟器中缺少位置的问题所需的步骤(来自 this answer ):

First, open ddms (Dalvik Debug Monitor). On Windows, navigate to the android-sdk\tools directory and run ddms.bat. The first line in the top-left pane will read something like "emulator-####" such as emulator-5560.

Open a command prompt window. Enter 'telnet localhost ####' substituting the number you found above. This will open a telnet window to your android emulator.

Enter the following command (substitute your own longitude & latitude, in that order, if you'd like):

geo fix -82.411629 28.054553

(I'm pretty sure you can add elevation as a third number.) The GPS icon will appear in the emulator's notification bar. Geolocation is now available. At this point, I could get location data in my app and in other apps, such as Maps.

关于javascript - Titan 地理定位在 Android 模拟器中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14146510/

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