An interesting way to implement Google Map Geocoding
Posted October 9th, 2007 by ServiceBeacon TeamThis is the first in a number of blog entries discussing some of the interesting technology and implementation methods used in the ServiceBeacon application.
Recently, we have added a car dealership map allowing people to find their car dealer in the system. To accurately map the locations and place dealership markers, we needed a mapping tool with geocoding capability. For those unfamiliar with the term “geocoding”, it describes the method of converting street address information into a global latitude/longitude combination. Some systems also produce a standardized format of the address which can be loaded back into the calling system. For companies dealing with mapping or with questionable address information, this technology can be a great tool. To provide that functionality for ServiceBeacon, we chose Google Maps and their geocoding functionality.
Why Google Maps? The technology is very powerful, response times are good, and most importantly, it can accurately discern different address formats which is great when your address quality is suspect.
While Google Maps and its geocoding abilities are quite powerful, it does have its own drawbacks. The number of addresses you can simultaneously geocode is limited. If you try to send too many requests (more than 10 in a short timespan), the application will start to respond to those additional locations with an error. This forces you to resend or delay in sending the address information. There is also a limit to the number of geocoding address you can do in a day. We have seen a site report the number is around 15,000 but we have not been able to confirm it. Lastly, while the response time is short, it still takes time to do the work. This means your user has to wait while the page starts to fill with markers as you geocode each location.
These drawbacks may not be problematic for some companies who have 10-20 locations to map but ServiceBeacon already has over 15,000 dealerships across North America and each person can try to view all of them every day. If we didn’t implement a strategy to reduce the data traffic, our site would quickly get bogged down in geocoding calls and maybe hit the upper daily limit.
To reduce the effect of these limitations and increase speed, we implemented an interesting strategy. Given the over 15,000 car dealership locations (and rising) we may have to map on a daily basis, we implemented a “check once, show many” strategy. The database has a flag determining if the address needs to be geocoded or not. If a dealership address has already been geocoded, the accurate latitude/longitude is sent to Google Maps and the dealership is marked. This happens quickly and is a JavaScript call locally to the web client. If it requires geocoding, the system sends the address via a JavaScript call to Google for analysis. Once returned, the information is mapped. Here is the interesting part. The address information including the accurate latitude/longitude pair is sent back to the database via an AJAX call. This allows the ServiceBeacon database to be updated with accurate data and also set the geocoded flag. This means only the first requester of that dealership is slowed down as it is geocoded. All other users will see the marker instantaneously. Another great feature of this model is as new dealerships get added or existing dealerships move, the system sets the flag to needing geocoding and when that dealership is requested, the new data seamlessly updates itself.
If you want to see it in action, try it out here. If you have any comments, please submit them as we are always interested in hearing from our car community.
More technology blogs to come….
The SB Team

