的Windows Phone 8 Geolocator不能设置desiredAccuracy =高,扎入PositionChanged事件事件、Phone、Windows、Geolocator

2023-09-04 03:45:24 作者:谜Ⅰ‘样旳女λ

背景:我深谙WPF / XAML,但新的Windows Phone 8

希望也只是一些愚蠢的事,我很想念......

我想DesiredAccuracy要高,但我也想挂接到PositionChanged事件。

在跌破code到达_GeoLocator.DesiredAccuracy = PositionAccuracy.High;它抛出一个异常中止。如果它关闭,一切正常,但我真的希望,精度高。

看来两者是相互排斥彼此的。

错误消息是:操作终止(从HRESULT异常:0x80004004(E_ABORT))。我有定位功能启用。

对违规code例:

  MainPage的公()
    {
        的InitializeComponent();

        _GeoLocator.MovementThreshold = 1;

        _GeoLocator.PositionChanged + =(Geolocator发件人,PositionChangedEventArgs参数)=>
        {
            // UpdateLocation(参数);
            Console.WriteLine(位置改变);
        };

        //这将抛出...为什么?如果我评论关闭POSITIONCHANGED以上,它工作正常。
        _GeoLocator.DesiredAccuracy = PositionAccuracy.High;
    }
 

解决方案 Windows Phone 8.1评测 脱胎换骨 的改变

您必须设置DesiredAccuracyPositionChanged事件处理程序之前(类似的问题)。

  _GeoLocator.MovementThreshold = 1;
_GeoLocator.DesiredAccuracy = PositionAccuracy.High;
_GeoLocator.PositionChanged + =(Geolocator发件人,PositionChangedEventArgs参数)=>
    {
        // UpdateLocation(参数);
        Console.WriteLine(位置改变);
    };
 

background: I'm well versed in WPF/XAML, but new to Windows Phone 8.

Hopefully there is just something stupid that I'm missing...

I want DesiredAccuracy to be high, but I also want to hook into the PositionChanged event.

When the below code reaches _GeoLocator.DesiredAccuracy = PositionAccuracy.High; it throws an abort. If it off, everything works but I really want high accuracy.

It seems the two are mutually exclusive of one another.

Error message is: Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT)). I have Location capabilities enabled.

Example of offending code:

    public MainPage()
    {
        InitializeComponent();

        _GeoLocator.MovementThreshold = 1;

        _GeoLocator.PositionChanged += (Geolocator sender, PositionChangedEventArgs args) =>
        {
            //UpdateLocation(args);
            Console.WriteLine("Position Changed");
        };

        //THIS WILL THROW...WHY??   IF I COMMENT OFF POSITIONCHANGED ABOVE, IT WORKS FINE.
        _GeoLocator.DesiredAccuracy = PositionAccuracy.High;
    }

解决方案

You have to set "DesiredAccuracy" before "PositionChanged" event handler (Similar question).

_GeoLocator.MovementThreshold = 1;
_GeoLocator.DesiredAccuracy = PositionAccuracy.High;
_GeoLocator.PositionChanged += (Geolocator sender, PositionChangedEventArgs args) =>
    {
        //UpdateLocation(args);
        Console.WriteLine("Position Changed");
    };

 
精彩推荐
图片推荐