ITsolutionWizard
asked on
Geo Google get different items
I have the codes below to get full address from Geo API google. It works fine
but now I need to get address, city, state, and zip. And I have no idea how to get them in c#.
I read the following article as well but it is in javascript
https://stackoverflow.com/questions/10926420/how-do-i-get-just-the-postal-code-from-a-reverse-geocode-result
but now I need to get address, city, state, and zip. And I have no idea how to get them in c#.
I read the following article as well but it is in javascript
https://stackoverflow.com/questions/10926420/how-do-i-get-just-the-postal-code-from-a-reverse-geocode-result
public static string GetAddress(string latitude, string longitude)
{
string locationName = "";
string url = string.Format("https://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false&key=AIzaSydsfBzalHtsdfsadfsadfasdfdsafTxZaIVQrePIK_Lfbv1QqPC_Xr5c", latitude, longitude);
XElement xml = XElement.Load(url);
if (xml.Element("status").Value == "OK")
{
locationName = string.Format("{0}", xml.Element("result").Element("formatted_address").Value);
}
else
{
locationName = xml.Element("status").ToString();
}
return locationName;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER