Titanium Mobile 在 iOS 上无法获得正确的准确度
我的编码有问题。我的代码似乎没有获得低于 1414 的准确度。
每当我打开谷歌地图并在那里获取我的位置时,它通常会在一秒钟内找到它。如果我切换回来,我会在几秒钟内看到正确的精度,然后它会切换回非常低的精度(1414)。
我做错了什么?
这是我的代码:
function reportPosition(e){
label.text = e.coords.longitude + " - " + e.coords.accuracy;
}
Ti.Geolocation.purpose = "Test";
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
Ti.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS;
Titanium.Geolocation.getCurrentPosition(reportPosition);
Titanium.Geolocation.addEventListener('location', reportPosition);
Titanium.Geolocation.addEventListener('heading', reportPosition);
I have a problem with my coding. My code just doesn't seem to be getting an accuracy lower then 1414.
Whenever I open google maps, and get my location there it finds it usually within a second. If I switch back I see a correct accuracy for a couple of seconds, and then it switches back to the very low accuracy (1414).
What am I doing wrong?
This is my code:
function reportPosition(e){
label.text = e.coords.longitude + " - " + e.coords.accuracy;
}
Ti.Geolocation.purpose = "Test";
Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;
Titanium.Geolocation.distanceFilter = 10;
Ti.Geolocation.preferredProvider = Titanium.Geolocation.PROVIDER_GPS;
Titanium.Geolocation.getCurrentPosition(reportPosition);
Titanium.Geolocation.addEventListener('location', reportPosition);
Titanium.Geolocation.addEventListener('heading', reportPosition);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于这个问题,您还有更多背景吗?
我已经运行了您的确切代码并收到了 10 到 183 之间的准确度,但从未更高。
我还将其分开,以确保“标题”不会调用报告虚假数字的相同方法。
我在我的模拟器和 iPhone 4S 上使用 Ti 1.7.2 编译 4.1。
您是否关闭了指南针干扰?当你说你从谷歌地图切换到你的应用程序时。您正在切换还是正在使用嵌入式地图?我尝试在地图和我的应用程序之间切换,准确性没有发生重大变化?
可能是硬件或位置不好? (尽管这并不能解释为什么使用谷歌地图后会得到好的结果)。您是否总是在应用程序启动时获得良好的结果,但结果却下降了?
显而易见的答案是,您没有做错任何事,并且您收到的位置/硬件的准确度是正确的。
Do you have any more context for this question?
I have ran your exact code and received accuracy of between 10 and 183 but never any higher.
I also split it up to make sure that 'heading' wasn't calling the same method reporting bogus numbers.
I compiled against 4.1 with Ti 1.7.2 on both my simulator and iPhone 4S.
Do you have compass interference turned off? When you say you switch from google maps to your app. Are you switching or are you using an embedded map? I tried switching between maps and my app with no major change to the accuracy?
Possibly bad hardware or location? (Although that wouldn't explain why you get good results after using google maps). Do you get good results always at the start of your app and they degrade?
The obvious answer would be that you are doing nothing wrong and that you are receiving the correct level of accuracy for the location/hardware where you are using it.
我遇到了同样的问题,发现 ACCURACY_BEST 选项一定存在问题。
很奇怪,但尝试使用更差的精度选项会给我更好的结果,只需尝试这样的事情:
然后我所做的是从 ACCURACY_NEAREST_TEN_METERS 开始,然后将其更改为 ACCURACY_BEST(在第一个位置读数中)。
在不同地点尝试过,第一次读数从 65 米开始,后来变为 10 - 5 米。
I had the same issue and discovered that there must be some issue with ACCURACY_BEST option.
Is weird but trying with a worse accuracy option gives me better results, just try something like this:
What I did then is to start with ACCURACY_NEAREST_TEN_METERS and then change it later to ACCURACY_BEST (in the first location reading).
Tried this at different locations and it starts with 65meters on first readings and goes to 10 - 5 meters later.