Titanium Mobile 在 iOS 上无法获得正确的准确度

发布于 2024-12-09 18:00:50 字数 682 浏览 0 评论 0原文

我的编码有问题。我的代码似乎没有获得低于 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

混浊又暗下来 2024-12-16 18:00:50

对于这个问题,您还有更多背景吗?

我已经运行了您的确切代码并收到了 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.

濫情▎り 2024-12-16 18:00:50

我遇到了同样的问题,发现 ACCURACY_BEST 选项一定存在问题。

很奇怪,但尝试使用更差的精度选项会给我更好的结果,只需尝试这样的事情:

Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS;

然后我所做的是从 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:

Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_NEAREST_TEN_METERS;

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文