Google Maps API V3 更新迁移指南

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

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

发布于 2010-09-04