glenreid

Maps in Container Dijits

Discussion created by glenreid on Dec 28, 2010
Latest reply on Dec 29, 2010 by glenreid
Kind of a follow up to this old post:

http://forums.esri.com/Thread.asp?c=158&f=2396&t=277953

Instead of a hard coded map size, I have a full map.  My problem has to do with the browser resize.  The active tab is based on a passed argument and the active tab's map is initialized with the dojo connect resize that you see in the samples.  The initial map's resizing works fine.

function initMap(map) {
 switch (map) {
  case "daily":
   dailyMap = new esri.Map("dailyMapDiv", {extent:initExtent, logo:false});
   dailyMap.addLayer(streets);
   var dailyResizeTimer;
   dojo.connect(dailyMap, 'onLoad', function() {
    dojo.connect(dijit.byId('dailyMapDiv'), 'resize', function() {
     clearTimeout(dailyResizeTimer);
     dailyResizeTimer = setTimeout(function() {
      dailyMap.resize();
      dailyMap.reposition();
     }, 500);
    });
   });
   break;

  case "monthly":
   monthlyMap = new esri.Map("monthlyMapDiv", {extent:initExtent, logo:false});
   monthlyMap.addLayer(satellite);
   var monthlyResizeTimer;
   dojo.connect(monthlyMap, 'onLoad', function() {
    dojo.connect(dijit.byId('monthlyMapDiv'), 'resize', function() {
     clearTimeout(monthlyResizeTimer);
     monthlyResizeTimer = setTimeout(function() {
      monthlyMap.resize();
      monthlyMap.reposition();
     }, 500);
    });
   });
   break;

  default:
          resisMap = new esri.Map("resisMapDiv", {extent:initExtent, logo:false});
   resisMap.addLayer(topo);
   var resisResizeTimer;
   dojo.connect(resisMap, 'onLoad', function() {
    dojo.connect(dijit.byId('resisMapDiv'), 'resize', function() {
     clearTimeout(resisResizeTimer);
     resisResizeTimer = setTimeout(function() {
      resisMap.resize();
      resisMap.reposition();
     }, 500);
    });
   });
 }
}


When another tab is selected, the new map is initialized, but the dojo.connect doesn't get fired and thus map resizing doesn't work.  Do I need to remove the old 'onload' from the first map even though it is a separate object?  Am even I able to do this?

Thanks,
Glen

Outcomes