I am successfully using a .NET (4.0) extension for accessing the Google Maps API. However, it is slooooow - like ~3 sec for the screen to update with the resulting mileage. Here is my (pseudo-)code in the dll:
using System; using System.IO; using System.Net; using System.Xml;
byte[] response; string url = "https://maps.googleapis.com/maps/api/distancematrix/xml?sensor=false&units=imperial&origins=<MyOrigin>&destinations=<MyDestination>";
using (WebClient wc = new WebClient()) { response = wc.DownloadData(url); }
MemoryStream ms = new MemoryStream(response); XmlReader reader = XmlReader.Create(ms);
reader.ReadToFollowing("distance"); reader.ReadToFollowing("value"); string strMeters = reader.ReadInnerXml(); int intMeters; Int32.TryParse(strMeters, out intMeters); return intMeters / 1609;
Nothing too fancy. I would think that doing this repeatedly would speed things up, so that the code is cached, but that doesn't help. Any suggestions on how to improve the response time?
|