【问题标题】:PositionChanged event not triggered in Windows 8 store app using xaml使用 xaml 在 Windows 8 商店应用程序中未触发 PositionChanged 事件
【发布时间】:2012-11-25 09:11:37
【问题描述】:

在下面的代码中,PositionChanged 事件从未被触发。我正在尝试在我的笔记本电脑中执行此代码。在我执行任何代码之前,有没有办法检查设备中的 GPS 是否可用。

private async void Track_Click_1(object sender, RoutedEventArgs e)

    {
        locator = new Geolocator();
        locator.DesiredAccuracy = PositionAccuracy.High;
        locator.MovementThreshold = 10;
        locator.ReportInterval = 2000;
        locator.PositionChanged += locator_PositionChanged;
        locator.PositionChanged +=  new TypedEventHandler<Geolocator, PositionChangedEventArgs>(OnPositionChanged);


    }

    void locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
    {
        throw new NotImplementedException();
    }

    void OnPositionChanged(Geolocator sender, PositionChangedEventArgs args)
    {

        dAltitude = Convert.ToDouble( args.Position.Coordinate.Altitude.ToString());
        dPrevLongitude = Convert.ToDouble(args.Position.Coordinate.Longitude.ToString());
        dPrevLatitude = Convert.ToDouble(args.Position.Coordinate.Latitude.ToString());
    }

【问题讨论】:

    标签: xaml windows-runtime winrt-xaml winrt-async


    【解决方案1】:

    启用互联网功能后解决。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多