GeoCoordinateWatcher 必须触发多少次?

发布于 2024-12-27 10:35:39 字数 364 浏览 2 评论 0原文

我的 Wp7(Mango)应用程序需要知道用户的位置,以便在数据库中搜索最近的对象。但我想在欢迎屏幕上显示结果,所以我需要尽快找到我的位置。我编写了一段代码,该代码启动 GeoCooperativeWatcher (高精度和最小阈值),并在第一次触发时停止它,并将位置发送到 Web 服务,该服务返回有问题的对象。

测试后,我去把它展示给城镇的另一边。我启动了它,但让大家觉得有趣的是,它显示了一个完全错误的结果 - 我知道为什么:它仍然认为我在家!

GPS 更新需要多长时间? 我如何知道我最终获得了当前位置?在停止之前我应该​​允许 GeoCooperativeWatcher 触发多少次?

My Wp7 (Mango) app needs to know the location of the user in order to search for the nearest object in the database. But I want to display the result on the welcome screen, so I need my location ASAP. I've written a code that starts the GeoCoordinateWatcher (on high precision and minimal threshold), and on the first firing it stops it, and sends the location to the webservice, which returns the object in question.

After I tested it, I went to present it, to the other side of the town. I started it and for everyone's amusement it showed a completely wrong result - I know why: it still thought I was at home!

How long does it take for the GPS to update? How will I know that I finally got my current location? How many times should I allow the GeoCoordinateWatcher to fire before stopping it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

半世晨晓 2025-01-03 10:35:39

在此处查看答案:

http:// /awkwardcoder.blogspot.com/2011/09/geo-location-on-wp7-dont-trust-first.html

基本上,不断要求更新,直到有一个在您的范围内开始向他们提出要求。

in PositionChanged

if ( (DateTime.Now - e.Position.TimeStamp.DateTime) < LocationTimeout)
  {
         //recent enough.
  } 

Check out the answer here:

http://awkwardcoder.blogspot.com/2011/09/geo-location-on-wp7-dont-trust-first.html

Basically, keep asking for updates until one is in the range from when you started requesting them.

in PositionChanged

if ( (DateTime.Now - e.Position.TimeStamp.DateTime) < LocationTimeout)
  {
         //recent enough.
  } 
尐籹人 2025-01-03 10:35:39

您有 StatusChanged 事件用于处理例如旧用户位置(在家)。当设备状态就绪时 - 您拥有当前位置(但可能不准确)。因此,如果您需要高精度位置,请使用 Horizo​​ntalAccuracy ;)

You have StatusChanged event for handling such as old user location (at home). When device status is ready - you have current location (but it can be inaccurate). So, use HorizontalAccuracy if you need high precision position ;)

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