Friday, March 5, 2010

Client-Side Geocoding Rocks!

Part of my job is to help partners with their code, making sure they are successfully implementing on Google Earth and Maps. The most common problem people come to me with is something like "Can you give me more quota, my http geocoding limit is reached." This is for the free Google Maps API. There's a simple solution. Don't do it!

The way the quota for the Google Maps API geocoder works is by IP address. If you put the geocoder in your JavaScript code (or Flash) it's rendering in the browser. And therefore counts against the IP address quota of the browser, not your site. If you have a single server side script that does an IP address lookup, it's going to be against the single IP address of the server. In other words, if your site is popular, you're going to run out quickly.

So, geocode in the browser and then send the geocode to do your lookup. We even allow for caching, as long as you're going to display on a Google Map or Google Earth. Caches can happen in the browser or server side.

A few additional things to think about:

1) Cloud computing services often share a range of IP addresses. If you're running on AWS or Google App Engine or any other cloud computing service, you particularly want to do client side geocoding, as you may be running quotas parallel to other apps.

2) Some mobile networks share IP addresses as well. That can cause problems for your client side software, as lots of people on their smart phones are looking at your map. If you anticipate heavy mobile use, you might consider having a server-side back-up as a fail-over. Try to geocode and if that doesn't work, send the address to your server for http geocoding.

3) If you're still running into problems with quota, you may consider a Maps API Premier license. Check out http://maps.google.com/getmaps for more information on the differences and to get started.

Do you know if there are any less expensive tiers of service for Maps Premiere? I know it may be a hard business decision but speaking to other devs in the industry, the $10K price point is quite steep for us startups.

Hi Mano, please check out the discussion at http://groups.google.com/group/google-maps-js-api-v3/browse_frm/thread/58bee37631e3a366/b220663ed0dc6fbe#b220663ed0dc6fbeit is about this subject and points out a problem with this method and the guys on your end say that what you're describing is not an intended use case.please help by straightening this out.Thanks,e.

@Elad these two positions are not contradictory. While it may not be an intended use case for JavaScript geocoding, the low quotas for http geocoding make it a necessity for data driven applications. I'll check with Ben to make sure there's not a real contradiction, but I don't think these are fundamentally different.

I'm just stuck here with the point "3" of my previous post, you told me that it is a IP-limit, however I found this other info in the link you gave me: https://developers.google.com/maps/articles/geocodestrat#client

"As geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows. Client-side geocoding will not face a quota limit unless you perform a batch of geocoding requests within a user session. Therefore, running client-side geocoding, you generally don't have to worry about your quota."

I'm kinda confused here and I certainly couldn't find other developers answers about this "sesion" or the real limits, except for the 2,500 a day map renderings from the serverside geocoding.

Not knowing exactly what a "session" is and its limits isn't the ideal scenario, however I understand that the main idea behind the "client geocoding" strategy is to help developers who make a good use of the API, so I'll stick to this:

"As geocoding limits are per user session, there is no risk that your application will reach a global limit as your userbase grows."

Thank you for your help and time.

PS: Is there any way to keen in touch & colaborate with you (you have a newer blog or something?) ? We've been doing some cool stuff here in with Google Maps for an important non-profit ONG here :)