My Experience with Google Maps API
Posted December 3rd, 2008 by MichaelA few weeks ago, I was tasked with improving the Google Maps feature for a major project at my internship. The map was part of a location-based search feature that is used on several different parts of the project. Essentially, a user enters a zip code and some other search parameters and a list of locations is generated and mapped out for them. While I am an experienced JavaScript programmer, and am familiar with a lot of related libraries and APIs, the Google Maps API is one that I had yet to introduce myself to. So when presented with this task, I jumped at the opportunity and began to read up on various API documentation that Google provides.
As expected, the features and functionality provided to individual developers by the API is impressive. One can achieve virtually all of the functions that Google’s own mapping service provides and then some. Since the project I was working on called for a fairly simple mapping system (the basic markers and info window we’re all accustomed too), I didn’t really get a chance to learn all of the nifty features provided by the API. Once I get some much needed free time over winter break, I am sure I will learn more about the API and possibly throw together a simple web application showcasing what I have learned.
In developing the mapping feature for this project, it became clear that I needed some sort of library to help manage the various pieces of data and events. I decided to create a Singleton Class that uses jQuery to help manage the map overall. My code uses the Module Pattern as described by Douglas Crockford. While the name, Module Pattern, may seem misleading (I think ‘Singleton Pattern’ does it better justice), the Module Pattern is a rather useful JavaScript design pattern that eliminates the need for global variables and enables some key Object Oriented Design concepts (private variables and methods anyone?). I decided to dub this simple class IMapper.