using
System;using
System.Data;using
System.Configuration;using
System.Collections;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;using
System.Xml;public
partial class Default2 : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
string street = "1600 Pennsylvania Ave"; string city = "Washington"; string state = "DC"; //string zip = "20500"; string geocoderUri = string.Format("http://rpc.geocoder.us/service/rest?address={0},{1},{2}", street, city, state); XmlDocument geocoderXmlDoc = new XmlDocument();geocoderXmlDoc.Load(geocoderUri);
XmlNamespaceManager nsMgr = new XmlNamespaceManager(geocoderXmlDoc.NameTable);nsMgr.AddNamespace(
"geo", @"http://www.w3.org/2003/01/geo/wgs84_pos#"); string sLong = geocoderXmlDoc.DocumentElement.SelectSingleNode(@"//geo:long", nsMgr).InnerText; string sLat = geocoderXmlDoc.DocumentElement.SelectSingleNode(@"//geo:lat", nsMgr).InnerText; double latitude = Double.Parse(sLat); double longitude = Double.Parse(sLong);Response.Write(
"Latitude: " + latitude + "<br /> Longitude: " + longitude);}
}
This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Thursday, February 12, 2009
Re: Get Longitude and Latitude from an Address sample, C# asp.net 2.0,3.5
Subscribe to:
Post Comments (Atom)
3 comments:
Hi
I got the below error :
Data at the root level is invalid. Line 1, position 1.
At this point
geocoderXmlDoc.Load(geocoderUri);
Can you help me
My Mail address is nj.nikhiljain@gmail.com
I think you have to add google dll in bin folder
which Dll has to be included.... plzz reply
Post a Comment