I’ve been working for a few months as the lead front-end developer on a site for Nike called ‘Playmaker’, which allows groups of friends to organise informal games of football with each other. We use Google Maps to plot the location of the pitch the players will be using for their game.
Something that had annoyed me for some time about the Google Maps AJAX API was that you always had to initialise the API during the load of your page. Considering the size of the script is in the region of 200kB, and involves creating an external connection to google.com, it can slow down the loading of your page by a noticable amount.
What I needed was to be able to download the API when it’s needed, e.g. if one’s map is hidden to start with, only to be displayed on a user click on a button.
Thankfully, the geniuses over at Google have finally included this functionality in their latest test release of the AJAX API.
Examples:
http://gmaps-samples.googlecode.com/svn/trunk/dynamicloading/commonloader.html
http://gmaps-samples.googlecode.com/svn/trunk/dynamicloading/scriptappend.html
My pages will be racing along in no time… thanks, Google!