我尝试使用以下代码来找出钛机器人的用户位置
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模拟器中
我错过了什么?提前致谢
最佳答案 您必须使用telnet连接到您的模拟器并“设置位置”.每次设置位置,您都将获得一个活动.
`
telnet localhost 5554(考虑到有时端口不同 – 你可以在窗口标题栏中看到它).
试试127.0.0.1 ……
连接到localhost.
逃脱角色是’^]’.
Android控制台:输入“帮助”以获取命令列表
好
geo fix 15.4548 12.4548(参数是经度,纬度(以度为单位))
好
放弃
`
请享用