With Google Maps API v3 come many changes. Generally the API is now very well structured and ad last it provides a decent namespace.  For example, the Marker object can be accessed via google.maps.Marker. When porting software written with API v2 to API v3 developers will notice some minor and major differences between both API versions. Unfortunately, migrating from version 2 to version 3 of the API requires more than just changing function names. Some of the functionality found in the API version 2 has been removed or changed.

The first step in using Google Maps API v3 consists in including the correct javascript file:

http://maps.google.com/maps/api/js?v=3&sensor=set_to_true_or_false&key=your_api_key

The second step in the migration process consists in renaming api calls and objects. The renaming follows the following pattern:

  • GMarker -> google.maps.Marker
  • GOverlay ->google.maps.Overlay
  • GEvent -> google.maps.Event

Having completed the renaming process does not guarantee the new code works, as some methods and concepts have changed between the two API versions:

  • A map’s type is not set anymore by using defined GMapType objects, but by setting a MapTypeId
  • An overlay is not added to the map by calling the map’s addOverlay method, but by calling the object’s setMap() method.
  • The GControl interface is not used anymore for adding custom controls to the map. In Google Maps API v3 custom controls are purely build with html, positioned on the map container and added the required event listeners.
  • For custom overlay types instead of inheriting from GOverlay, in v3 custom overlays are inherited from OverlayView

See Google Maps API v3 for a complete reference.