0

ReverseGeocodeQuery дает ошибкуReverseGeocodeQuery дает ошибку

1.in "GeoCoordinate (47,60887, -122,34094);" метод должен иметь тип возвращаемого

2.in "reverseGeocode.GeoCoordinate линия" reverseGeocode является полем но его использовали как тип ..

ReverseGeocodeQuery reverseGeocode = new ReverseGeocodeQuery(); 
reverseGeocode.GeoCoordinate = new GeoCoordinate(47.60887, -122.34094); 
reverseGeocode.QueryCompleted += reverseGeocode_QueryCompleted; 
reverseGeocode.QueryAsync(); 
void reverseGeocode_QueryCompleted(objectsender,QueryCompletedEventArgs<IList<MapLocation>> e) 
{ 
MapAddress geoAddress = e.Result[0].Information.Address;   
} 

Я использовал пространство имен - используя Microsoft.Phone.Maps.Services;

как исправить эту ошибку ..

ответ

1

ПОЛУЧИЛИ ОТВЕТ

GeoCoordinateWatcher myLocationWatcher; 
private GeoCoordinate MyCoordinate = null; 
private async void GetCurrentCoordinate() 
    { 
     Geolocator geolocator = new Geolocator(); 
     geolocator.DesiredAccuracy = PositionAccuracy.High; 

     try 
     { 
      Geoposition currentPosition = await geolocator.GetGeopositionAsync(TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10)); 
      _accuracy = currentPosition.Coordinate.Accuracy; 

      MyCoordinate = new GeoCoordinate(currentPosition.Coordinate.Latitude, currentPosition.Coordinate.Longitude); 

      if (MyReverseGeocodeQuery == null || !MyReverseGeocodeQuery.IsBusy) 
      { 
       MyReverseGeocodeQuery = new ReverseGeocodeQuery(); 
       MyReverseGeocodeQuery.GeoCoordinate = new GeoCoordinate(MyCoordinate.Latitude, MyCoordinate.Longitude); 
       LongitudeTextBlock.Text = MyCoordinate.Longitude.ToString(); 
       LatitudeTextBlock.Text = MyCoordinate.Latitude.ToString(); 
       MyReverseGeocodeQuery.QueryCompleted += ReverseGeocodeQuery_QueryCompleted; 
       MyReverseGeocodeQuery.QueryAsync(); 
      } 

     } 
     catch (Exception ex) 
     { 
      // ... 

     } 

    } 


    public void ReverseGeocodeQuery_QueryCompleted(object sender, QueryCompletedEventArgs<IList<MapLocation>> e) 
    { 
     if (e.Error == null) 
     { 
      if (e.Result.Count > 0) 
      { 
       MapAddress address = e.Result[0].Information.Address; 
       labelResults.Text = "Current Location: " + address.City + ", " + address.State; 
      } 
     } 
    } 


    public void Button_Click(object sender, RoutedEventArgs e) 
    { 
     GetCurrentCoordinate(); 

    } 

 Смежные вопросы

  • Нет связанных вопросов^_^