2011-09-27 55 views
4

我尝试下面的代码在Android的钛Android的地理位置无法得到你的位置误差在模拟器

application.Ti.App.GeoApp = {}; 
Ti.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS; 
Ti.Geolocation.purpose = "testing"; 
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST; 
Titanium.Geolocation.distanceFilter = 10; 
if(Titanium.Geolocation.locationServicesEnabled === false) { 
    Ti.API.debug('Your device has GPS turned off. Please turn it on.'); 
} 
function updatePosition(e) { 
    if(! e.success || e.error) { 
    alert("Unable to get your location."); 
    Ti.API.debug(JSON.stringify(e)); 
    Ti.API.debug(e); 
    return; 
    } 
    Ti.App.fireEvent("app:got.location", { 
    "coords" : e.coords 
    }); 
}; 

Ti.App.addEventListener("app:got.location", function(d) { 
    Ti.App.GeoApp.f_lng = d.longitude; 
    Ti.App.GeoApp.f_lat = d.latitude; 
    Ti.API.debug(JSON.stringify(d)); 
    Ti.Geolocation.removeEventListener('location', updatePosition); 

    alert(JSON.stringify(d)); 
}); 
Titanium.Geolocation.getCurrentPosition(updatePosition);  
Titanium.Geolocation.addEventListener('location', updatePosition); 

运行此代码后,找出用户的位置,它提供了提醒* 无法获取您的位置。 *在Android模拟器 我失踪了什么东西?在此先感谢

回答

2

您必须使用telnet连接到您的模拟器和“设置位置”。每次你设置的位置,你会得到一个事件。

` telnet localhost 5554(考虑到有时端口是不同的 - 你可以在窗口标题栏中看到它)。

尝试127.0.0.1 ...

连接到本地主机。

转义字符是'^]'。

Android的控制台:键入 'help' 以命令的列表

OK

地理修复15.4548 12.4548(参数经度,在纬度)

OK

退出 `

享受

相关问题