Niyo

getLocationName

Jan 19th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1.     /// <summary>
  2.         /// Get Location name by lat and long
  3.         /// </summary>
  4.         private async void getLocationName()
  5.         {
  6.             Geoposition geoposition = await getLocation(1);
  7.  
  8.             List<MapLocation> locations;
  9.             ReverseGeocodeQuery query = new ReverseGeocodeQuery();
  10.             query.GeoCoordinate = new GeoCoordinate(geoposition.Coordinate.Latitude, geoposition.Coordinate.Longitude);
  11.             query.QueryCompleted += (s, e) =>
  12.             {
  13.                 if (e.Error == null && e.Result.Count > 0)
  14.                 {
  15.                     locations = e.Result as List<MapLocation>;
  16.  
  17.                     Model.LocationName = locations[0].Information.Address.Street;
  18.                     // Do whatever you want with returned locations.
  19.                     // e.g. MapAddress address = locations[0].Information.Address;
  20.                 }
  21.             };
  22.             query.QueryAsync();
  23.         }
Advertisement
Add Comment
Please, Sign In to add comment