Windows Phone的8.1位置跟踪 [英] Windows Phone 8.1 location-tracking

查看:202
本文介绍了Windows Phone的8.1位置跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,连续发送设备的位置,以Web服务的应用程序。展望文档中,我发现Geolocation类和一些文章,其中位置跟踪讨论:

I want to realize an App that continuously send device's position to a web service. Looking in the documentation, I've found Geolocation class and some articles where position-tracking is discussed:

  • How to continuously track the phone's location for Windows Phone 8
  • How to run location-tracking apps in the background for Windows Phone 8

实现在这些文章中讨论这两个示例项目,我注意到,在geolocator_PositionChanged()事件不会在每个位置更新解雇。有2执行的事件之间的延时(约10/15分钟)。奇怪的是,出现这种情况,即使应用在前台执行(不仅是在后台)。我使用Windows Phone模拟器。

Implementing both example projects discussed in these articles, I've noticed that the geolocator_PositionChanged() event is not fired at every position update. There is a delay (about 10/15 minutes) between 2 execution of the event. The strange thing is that this happens even when the App executes in foreground (not only in background). I'm using Windows Phone emulator.

在我的应用我有一个地图控件,我需要表现出用户的位置,所以,我需要的geolocator_PositionChanged()事件正确地解雇了每个位置的更新,无延迟。

In my App I have a map control where I need to show user's position and, so, I need that the geolocator_PositionChanged() event be correctly fired for each position update, without delays.

1)如何跟踪(无延迟)设备的位置使用Geolocator类?

1) How can I track (without delays) the device's position using Geolocator class?

搜索在网络上,我发现了GeoCoordinateWatcher类,提供设备的时间可持续位置追踪。这是代码:

Searching over the network, I've found the GeoCoordinateWatcher class, that provides continuosly position-tracking of the device. This is the code:

public MainPage()
{
    InitializeComponent();
    this.GetCoordinate();
}

private void GetCoordinate()
{
    var watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High)
    {
        MovementThreshold = 1
    };
    watcher.PositionChanged += this.watcher_PositionChanged;
    watcher.Start();
}

private void watcher_PositionChanged(object sender, GeoPositionChangedEventArgs<GeoCoordinate> e)
{
    //Get position data
    var pos = e.Position.Location;
    //Update mypos object
    mypos.update(pos.Latitude, pos.Longitude);
    //Update data on the main interface
    MainMap.SetView(mypos.getCoordinate(), MainMap.ZoomLevel, MapAnimationKind.Parabolic);
}



它的工作原理:watcher_PositionChanged()事件无延迟发射

It works: watcher_PositionChanged() event is fired without delays.

2)为什么GeoCoordinateWatcher没有延迟?是什么GeoCoordinateWatcher阶级和阶级Geolocator之间的区别?

2) Why the GeoCoordinateWatcher does not have delays? What is the difference between GeoCoordinateWatcher class and Geolocator class?

最后,应用程序应该发送设备的位置,Web服务,即使它不活动。所以,我需要一个后台任务。由于提出由Romasz这里,我可以用Geolocator类有一些限制。

Finally, the App should send device's position to the web service even when it is not active. So, I need a background task. As proposed here by Romasz, I can use Geolocator class with some limitations.

3)我可以用GeoCoordinateWhatcher在后台?如果是的话,怎么样?

3) Can I use GeoCoordinateWhatcher in background? If yes, how?

我的目标是要实现一个位置跟踪应用程序没有延迟,即使工作在后台。什么是做到这一点的最好方法是什么?该应用程序应该跟踪设备的位置,并不断更新的Web服务(在后台,即使)。我怎样才能做到这一点?什么是最好的方法呢?我知道有关Windows Phone应用生命周期,我可以接受在后台执行一些限制。有什么背景的限制?

My goal is to realize a position-tracking App without delays, that even works in background. What is the best way to do this? The App should track the device's position and continuously update the web service (even when in background). How can I do this? What is the best approach? I know about the Windows Phone Apps lifecycle and I can accept some limitations for the background execution. What are the background limits?

推荐答案

不幸的Windows Phone 8.1不支持后台连续跟踪。如果你想要这个功能,你就必须开发一款Windows Phone 8应用来代替。希望他们会解决这个问题了8.2,9或什么是下一个!

Unfortunately Windows Phone 8.1 doesn't support continuous tracking in the background. If you want this feature you'll have to develop a Windows Phone 8 app instead. Hopefully they'll fix this for 8.2, 9 or whatever's next!

这篇关于Windows Phone的8.1位置跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆