public static async Task <GeocodeService.GeocodeResponse> GetLocation(Geoposition pos) { if (pos.Coordinate.Latitude != 0) { var reverseRequest = GeocodeServiceHelper.GetReverseRequest(pos.Coordinate.Latitude, pos.Coordinate.Longitude); var client = GeocodeServiceHelper.GetClient(); return(await Task.Run(() => client.ReverseGeocodeAsync(reverseRequest))); } return(new GeocodeService.GeocodeResponse()); }
public static async Task <string> GetPostalCode(Geoposition pos) { var postCode = pos.CivicAddress.PostalCode ?? string.Empty; if (postCode.Length <= 0 && pos.Coordinate.Latitude != 0) { var reverseRequest = GeocodeServiceHelper.GetReverseRequest(pos.Coordinate.Latitude, pos.Coordinate.Longitude); var client = GeocodeServiceHelper.GetClient(); var geocodeResponse = await Task.Run(() => client.ReverseGeocodeAsync(reverseRequest)); if (geocodeResponse.Results != null) { postCode = geocodeResponse.Results[0].Address.PostalCode; } } return(postCode); }