public async Task <IGoogleMapsAddress> ReverseGeoCodeAsync(string placeId, GoogleMapsGeoCoderOptions googleMapsGeoCoderOptions) { try { var googleMapsGeoCodingApiResponse = await InternalReverseGeoCodeAsync(placeId); return(HandleGoogleMapsGeoCodingApiResponse(googleMapsGeoCodingApiResponse, googleMapsGeoCoderOptions)); } catch (GoogleMapsGeoCoderException) { throw; } catch (Exception ex) { throw new GoogleMapsGeoCoderException( "An error occured when trying to GeoCode, please check InnerException", ex); } }
private IGoogleMapsAddress HandleGoogleMapsGeoCodingApiResponse(GoogleMapsGeoCodingApiResponse googleMapsGeoCodingApiResponse, GoogleMapsGeoCoderOptions googleMapsGeoCoderOptions) { if (googleMapsGeoCodingApiResponse.Status == GoogleMapsGeoCodingApiStatus.Ok) { if (googleMapsGeoCoderOptions != null && googleMapsGeoCoderOptions.MustCacheFullResponse) { GoogleMapsGeoCodingApiResponse = googleMapsGeoCodingApiResponse; } var googleMapsAddress = ConvertGoogleMapsGeoCodeResultToGoogleMapsAddress(googleMapsGeoCodingApiResponse.GoogleMapsGeoCodingApiResults[0]); return(googleMapsAddress); } throw new GoogleMapsGeoCoderException(googleMapsGeoCodingApiResponse.Status, "An error occured when trying to GeoCode, check your api and the input passed", null); }