Windows Phone 8.1 地理位置速度始终为 5.8



我正在使用地理位置和Postition更改事件来获取设备位置的坐标。

       private async void StartGpsMonitoring()
    {
        if (locator == null)
        {
            locator = new Geolocator();
        }
        if (locator.LocationStatus == PositionStatus.Disabled)
        {
            //throw new Exception();
            MessageDialog noGpsDialog = new MessageDialog("Location services are disabled, please enable location services");
            noGpsDialog.Commands.Add(new UICommand("Location Settings", new UICommandInvokedHandler(this.CommandInvokedHandler), 0));
            noGpsDialog.Commands.Add(new UICommand("Cancel", new UICommandInvokedHandler(this.CommandInvokedHandler), 1));
            await noGpsDialog.ShowAsync();
        }
        if (locator != null)
        {
            //locator.MovementThreshold = 3;
            locator.ReportInterval = 1;
            locator.DesiredAccuracy = PositionAccuracy.High;
            locator.PositionChanged +=
                new TypedEventHandler<Geolocator,
                    PositionChangedEventArgs>(locator_PositionChanged);
        }
    }
       private async void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs e)
    {
        string speed = string.Empty;
        await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
        {
            Geoposition geoPosition = e.Position;
            if (e.Position.Coordinate.Speed != null)
            {
                 speed = e.Position.Coordinate.Speed.Value.ToString(); // always 5.8
            }
            geolocation = geoPosition.Coordinate.Point.Position.Latitude.ToString() + " " +
                              geoPosition.Coordinate.Point.Position.Longitude.ToString() + "Speed = " +
                              speed;

            var textBlockStatus =
                ControlHelper.FindChildControl<TextBlock>(JourneyTrackerSection, "TextBlockStatus") as TextBlock;
            textBlockStatus.Text = geolocation;
        });
    }

我也在尝试获取速度值。但是在使用模拟器时,无论模拟器上是否设置了限速/步行/骑自行车,我总是得到 5.8,并且仍然从静态位置获得 5.8。

谁能说明一下为什么?它只是模拟器吗?如果我使用真实设备,我会得到准确的结果吗?很难开发一个位置速度应用程序,每次我想调试/运行它时我都必须跑出去。

任何帮助非常感谢。

以为我会发布一些关于我设法找到的细节,以防将来有人遇到这种情况。看起来这是因为它在模拟器上运行。设法遇到了一些关于使用地理定位代码的有限细节以及有关它特定于硬件的一些细节。在我设法掌握了Windows手机进行测试后,模拟器无法达到速度。在实际设备上完美运行。

这Microsoft非常烦人。 这意味着每次我需要测试我的应用程序时,我都必须开车出去。使GPS模拟器完全无用!

最新更新