Google API

Well Google doesn’t like you to use their maps api unless you pay them 10 grand for enterprise use, so we decided to go a slightly different route. The problem was that G blocked the service to our IP address for 24 hours after repeatedly using the service. Thanks G!

 Instead of using the API we used the Google maps online service, passing the address as part of a query string and then parsing the results. Although this is a pain to have to parse the resulting html from the maps.com service, it still works and the results ate consistent, although, be aware, the lat and long results from the API are different than from maps.com!

Here’s how to do it in .NET

‘first we create a request
Dim req As HttpWebRequest = CType(WebRequest.Create(“http://maps.google.com/maps?oi=map&output=js&q=” + paddress), HttpWebRequest)
req.Method =
“POST”
‘set the content length of the string being posted
‘create the stream amd write it and close
req.ContentLength = 0
req.ContentType =
“text/xml”
‘now get the response
Dim res As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)

‘read it into a stream and close
Dim sr As New System.IO.StreamReader(res.GetResponseStream)
PostGEOOut = sr.ReadToEnd

Once you have the resulting html you will need to parse it to get the results. I will post that code soon

 

, , , , , , , , ,

No comments yet.

Leave a Reply