Browsing Posts in Google Maps API

The Google Maps Javascript API Version 2 has been officially deprecated as of May 19, 2010. The V2 API will continue to work as per our deprecation policy, but we encourage you to migrate your code to version 3 of the Maps Javascript API.

Google will issue an announcement if the current version of the Service will be deprecated. For a period of 3 years after an announcement (the “Deprecation Period”), Google will use commercially reasonable efforts to continue to operate the Deprecated Version of the Service and to respond to problems with the Deprecated Version of the Service deemed by Google in its discretion to be critical. During the Deprecation Period, no new features will be added to the Deprecated Version of the Service.

Google Maps v3 has bought about quite a few changes. One of the biggest notes for me was the lack of a v3 equivalent of GDownloadUrl(); a function previously included in v2 to make asynchronous calls to a script file. Google took a step in assuming that most people these days, in addition to their API, are using some form of Javascript library (Mootools, jQuery etc...) and now you need to form your own XMLHttpRequest be it with traditional Javascript or with a library wrapper function. In Mootools' case it's Request() class.

Another nice fall out of upgrading to v3 is the need, or rather lack of it, to specify an API key! With v2 I had to create multiple API keys for the production environment servers. With v3 this is no longer the case as API keys are no longer required. Nice!

I'll add more to this post as I find it.

I ran across a little problem today where an application written for our website, and running the Google Maps API was 'causing the browser to crash, but as always with 'quirks'...  only in IE6!

After some time fiddling around on the internet and reading quite a few interesting articles about the stability of the Google Maps API within IE6 I found a few things listed as the most common causes : (http://www.easypagez.com/maps/ieworking.html)

  • Script position. Make sure the Google Maps API script is called in either the head of your HTML or at the very end. Embedding within HTML should be avoided.
  • Make sure a valid doctype is declared. Remember the xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" attributes need to be added if you are presenting polylines in mapping applications
  • Ensure you have set a size for your google_map DIV
  • In your javascript make sure that the variable you assign new GMap2(); to is unique. Commonly it is assigned as var map = new GMap2(); make sure that variable is unique.
  • Good practice is to ensure your document W3C validates. http://validator.w3.org/ Clean (X)HTML is a great place to start.

Other things to be aware of. In the script src tag Google passes the major script version into the query string. http://maps.google.com/maps?file=api&v=2 BUT... this can be, although not recommended, also be used to pass in minor version stamps too. i.e. http://maps.google.com/maps?file=api&v=2.117

For a list of API Version Changes refer to this Google page. http://groups-beta.google.com/group/Google-Maps-API/web/api-version-changes