Google Maps API Tutorial

© 2007 Mike Williams

 

Tweaking GOverviewMapControl in v2.93

In v2.93, the code for the map controls is moved into a separate module which doesn't get loaded until you create the first map control. All the documented map control Methods work correctly [except that control.printable() and control.selectable() return "undefined" instead of "false"] but some undocumented features of GOverviewMapControl are not available until after the conrol_api module has finished loading.

In previous versions of the API you could write

      var overlayControl = new GOverviewMapControl();
      map.addControl(overlayControl);
      var overmap = overlayControl.getOverviewMap();
      var overmapdiv = document.getElementById('map_overview');
From v2.93, those undocumented features no longer work because the GOverviewMapControl doesn't actually exist until a few hundred milliseconds later, after the code that handles it has been loaded. You have to wait for the module to be loaded before those features become accessible. Or, alternatively, you could stop using those undocumented features.

The event that is triggered when the code module has been loaded doesn't appear to be accessible, and waiting for a fixed time period carries the risk that it might fail for a user with slower Internet connectivity or when the Google server is busy.

What you could do is wait for a short while, and check to see if the feature is active, and wait again if it isn't. Like this:

      var overlayControl = new GOverviewMapControl();
      map.addControl(overlayControl);
      setTimeout("checkOverview()",100);
   ...
      function checkOverview() {
        overmap = overlayControl.getOverviewMap();
        if (overmap) {      
          ...
        } else {
        setTimeout("checkOverview()",100);
      }
    }
This example logs the availability of .getOverviewMap() and "map_overview".

This example performs the same teaks as described here for the earlier versions of the API.

Back to Mike's Homepage
Up to the start of this tutorial