Submit Your Site For Free!

Email Address:
* URL:
*
*Indicates Mandatory Field

Terms & Conditions

CProgramTrends
FlashNewz
DevWebPro








Calculating An Address Based On GEO Coordinates

By Mads Kristensen
Expert Author
Article Date: 2008-11-20

Google's maps API now supports reversed GEO lookup which allows you to find an address based on geo coordinates.  All you need is a latitude, a longitude and this handy method:


privateconststring endPoint = "http://maps.google.com/maps/geo?q={0},{1}&output=xml&sensor=true&key=YOURKEY";

 

privatestaticstring GetAddress(double latitude, double longitude)

{

  string lat = latitude.ToString(CultureInfo.InvariantCulture);

  string lon = longitude.ToString(CultureInfo.InvariantCulture);

  string url = string.Format(endPoint, lat, lon);

 

  using (WebClient client = newWebClient())

  {

    string xml = client.DownloadString(url);

    XmlDocument doc = newXmlDocument();

    doc.LoadXml(xml);

 

    XmlNode node = doc.ChildNodes[1].FirstChild.ChildNodes[2].ChildNodes[0];

    return node.InnerText;

  }

}

It returns the address as a string.

Comments


About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/



Newsletter Archive | Article Archive | Submit Article | Advertising Information | About Us | Contact

C Programming Trends is an iEntry, Inc. ® publication - 1998-2009 All Rights Reserved Privacy Policy and Legal