2

Is there a way to use the response from the Google directions web service called, for example from C# code like this:

var url = System.String.Format(@"http://maps.googleapis.com/maps/api/directions/xml?origin={0}&destination={1}&sensor=false", 
  addressFrom, addressTo);
var result = XElement.Load(url);

And after that display the result on map; OR it must be done completely with JavaScript using the Google maps JavaScript API described here?

VMAtm
  • 27,943
  • 17
  • 79
  • 125
GoG
  • 310
  • 2
  • 6
  • 13

1 Answers1

0

Try using System>Xml.Linq and create a method that return IEnumberable Elelment

See Details Below

using System.Xml.Linq

        string mapurl = "http://maps.google.com/?q= from " + sourceaddres + " to " + destaddr + "&output=kml&view=text";
        XDocument mapsdocument = XDocument.Load(mapurl);
        XNamespace myNameSpace = XNamespace.Get("http://earth.google.com/kml/2.0");
        IEnumerable<XElement> myRoute = mapsdocument.Element(myNameSpace + "kml").Element(myNameSpace + "Document").Elements(myNameSpace + "Placemark").Elements(myNameSpace + "name");
        IEnumerable<XElement> myDescp = mapsdocument.Element(myNameSpace + "kml").Element(myNameSpace + "Document").Elements(myNameSpace + "Placemark").Elements(myNameSpace + "description");

   you can wrap this in a method and set return to IEnumerable<XElement>
MAK
  • 1
  • 1