Welcome to weblogs.com.pk Sign in | Join | Help

ASP.NET Applications

Discuss and share about ASP.NET Development
Google Maps KML and LINQ to Display Driving Directions
The important part is to retrieve the KML file (XML based standard) from Google Maps (refer to urlString). Once we have the KML file, we create an XMLDataSource control, retrieve the XmlDocument's InnerXml. After that, we parse the elements to retrieve the directions which are placed in the <name> element under kml/Document/Placemark. 
Dim fromAddress As String = Server.HtmlEncode(txtboxSourceAddress.text)
Dim toAddress As String = Server.HtmlEncode(txtboxDestinationAddress.text)
Dim urlString As String = String.Format("http://maps.google.ca/?q=From {0} to {1}&output=kml&view=text", fromAddress, toAddress)
Dim xmlDataSource2 As New XmlDataSource()
xmlDataSource2.DataFile = urlString
Dim xdoc As XDocument = XDocument.Parse(xmlDataSource2.GetXmlDocument().InnerXml)
Dim ns As XNamespace = XNamespace.Get("http://earth.google.com/kml/2.0")
Dim ele = xdoc.Element(ns + "kml").Element(ns + "Document").Elements(ns + "Placemark").Elements(ns + "name")
GridView1.DataSource = ele.Take(ele.Count - 1)
I have used the XmlDataSource control in this example because this is a code snippet from another project that I worked on. However, we can also use
Dim xdoc As XDocument = XDocument.Load(urlString)
The above line of code would load the KML file from remote server into xdoc. The remaining code remains same from this step onwards.
Posted: Tuesday, January 06, 2009 1:21 PM by aspnet
Filed under: , ,


xxfovm said:


# January 8, 2009 5:32 PM

idottgoxAlomi said:

Hey everyone

Can I get some advice on [url=http://www.myteethwhiteningonline.com]Teeth Whitening[/url] systems??

I would be very happy if ya'll could give any help.

# January 18, 2009 7:08 PM
Anonymous comments are disabled