在下面的代码中,永远不会触发 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());
}