C# and Google Geocoding Web Service v3

Need to geocode addresses using the v3 Google Geocoding Web Service? There are some good reasons to choose the new v3 edition — most importantly, you don’t need an API key. You could use geocoding.net which — at the time of writing — has some support for v3. I decided to hack up my own wrapper though, and using Windows Communication Foundation, it turned out to be really simple! Note that if you need more of the attributes returned by the Web Service, you should add them to the DataContract classes.

If you need to geocode a lot of addresses, you need to manage your request rate. Google will help you throttle requests by returning OVER_QUERY_LIMIT statuses if you are going too fast. I use the method below to manage this. It’s decidedly unelegant, please post a reply if you come up with something better.

michael brehmsays:

Thanks for this information. Helped me to understand the json structures returned from google geocoding-service.
I added the location type to geometry. Gives you information about how precise the returned geocodes are.

Perrysays:

Actually, moving away from the “key” model of v2 is not beneficially in some environments. The v3 api looks at the IP from which requests are coming. If you happen to share rackspace at an ISP with other applications that are doing the same thing, you may hit the “OVER_QUERY_LIMIT” before your application has made 2500 requests. Decidedly inconvenient and a very poor model in my opinion. The key was much better.