Windows phone 8 在Windows Phone 8中获取公民地址

Windows phone 8 在Windows Phone 8中获取公民地址,windows-phone-8,geolocation,Windows Phone 8,Geolocation,我正试图通过WP8中的地理定位器获取公民地址。但它抛出一个系统。NullReferenceException private void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args) { Dispatcher.BeginInvoke(() => { LatitudeTextBlock.Text = args.Position.Coordin

我正试图通过WP8中的地理定位器获取公民地址。但它抛出一个系统。NullReferenceException

private  void geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
{
     Dispatcher.BeginInvoke(() =>
      {
           LatitudeTextBlock.Text = args.Position.Coordinate.Latitude.ToString();
           LongitudeTextBlock.Text = args.Position.Coordinate.Longitude.ToString();
           Tblock.Text = args.Position.CivicAddress.Country;
      });
}
已经尝试了地理定位。仍然抛出异常。尝试了条件检查,没有用。请帮忙

[更新]

点击按钮:

private void TrackLocation_Tap(object sender, System.Windows.Input.GestureEventArgs e)
{
     Geolocator geolocator = new Geolocator();
     geolocator.DesiredAccuracy = PositionAccuracy.High;
     geolocator.MovementThreshold = 1; // This units are in Meters
     geolocator.StatusChanged += geolocator_StatusChanged;
     geolocator.PositionChanged += geolocator_PositionChanged;
     TrackLocation.Content = "Stop Tracking";
}

如果您想获取职位的地址,那么我建议您使用ReverseGeocodeQuery API和地理定位器API获取的职位,作为参考实现,我在

中提供了一个示例,您在哪一行获得异常?Tblock.Text=args.position.CivicAddress.Country;你能提供更多的代码吗?完成。geolocator_PositionChanged仅包含用于检查定位器状态的开关盒。它很长,这就是为什么我没有加上它。公民工厂?这是从哪里来的?
        var reportstatus = CivicFactory.Status;

        if (reportstatus == 4)
        {     
            var report = CivicFactory.CivicAddressReport;

            // Display the properties.
            tx1.value = report.AddressLine1;
            tx2.value = report.AddressLine2;
            tx3.value = report.City;
            tx4.value = report.StateProvince;
            tx5.value = report.CountryRegion;
            tx6.value = report.PostalCode;
            tx7.value = GetTimeString(report.Timestamp); 
        }
        else
        {
            alert("No location data provider available.");
        }