Skip to content

Commit

Permalink
Merge pull request #13 from nicolocarpignoli/master
Browse files Browse the repository at this point in the history
added GetAddressListFromAddress feature
  • Loading branch information
sethwebster authored Apr 21, 2017
2 parents 43b8813 + 0394a26 commit da0136d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions GoogleMaps.LocationServices/GoogleLocationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,40 @@ public MapPoint GetLatLongFromAddress(AddressData address)
return GetLatLongFromAddress(address.ToString());
}

/// <summary>
/// Gets an array of string addresses that matched a possibly ambiguous address.
/// </summary>
/// <param name="address">The address.</param>
/// <returns></returns>
/// <exception cref="System.Net.WebException"></exception>
public string[] GetAddressesListFromAddress(string address)
{

XDocument doc = XDocument.Load(string.Format(APIUrlLatLongFromAddress, Uri.EscapeDataString(address)));
var status = doc.Descendants("status").FirstOrDefault().Value;

if (status == "OVER_QUERY_LIMIT" || status == "REQUEST_DENIED")
{
throw new System.Net.WebException("Request Not Authorized or Over QueryLimit");
}

var results = doc.Descendants("result").Descendants("formatted_address").ToArray();
var addresses = (from elem in results select elem.Value).ToArray();
if (addresses.Length > 0) return addresses;
return null;
}

/// <summary>
/// Gets an array of string addresses that matched a possibly ambiguous address.
/// </summary>
/// <param name="address">The address.</param>
/// <returns></returns>
/// <exception cref="System.Net.WebException"></exception>
public string[] GetAddressesListFromAddress(AddressData address)
{
return GetAddressesListFromAddress(address.ToString());
}


/// <summary>
/// Gets the directions.
Expand Down

0 comments on commit da0136d

Please sign in to comment.