Link to home
Start Free TrialLog in
Avatar of ITsolutionWizard
ITsolutionWizardFlag for United States of America

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 

        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;
        }

Open in new window

Avatar of ITsolutionWizard
ITsolutionWizard
Flag of United States of America image

ASKER

any helps?
ASKER CERTIFIED SOLUTION
Avatar of Sean Corcoran, JD
Sean Corcoran, JD
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial