When is onLoad event triggered using esri.arcgis.utils.createMap?

868
2
Jump to solution
11-20-2012 10:52 AM
JoanneMcGraw
Occasional Contributor III
Many of the JavaScript API Samples show a map created and the "resize" event trapped as follows:

map = new esri.Map("mapDiv", {      extent: new esri.geometry.Extent(17198,6008256, 506394, 6497452, new esri.SpatialReference({wkid: 102100 })) });  dojo.connect(map, 'onLoad', function(theMap) {     dojo.connect(dijit.byId('map'), 'resize', map,map.resize); });


How would you do same if you were using esri.arcgis.utils.createMap() with a map id instead? That is, as far as I can tell, by the time I actually have the map object to pass to the dojo.connect, its onLoad event has already happened automatically (unlike above, where I can add the event listener and then add the layers to the map).

Am I understanding this correctly? And, if so, what would be the appropriate event to listen for to do this when doing a createMap vs. new esri.Map?

Cheers
jtm
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor
You can check to see if the map's been loaded if it has just add the resize code. If it hasn't then hook up the event:

    if (map.loaded) {           this.initUI();         } else {           dojo.connect(map, "onLoad", function () {             this.initUI();           });      }

View solution in original post

0 Kudos
2 Replies
KellyHutchins
Esri Frequent Contributor
You can check to see if the map's been loaded if it has just add the resize code. If it hasn't then hook up the event:

    if (map.loaded) {           this.initUI();         } else {           dojo.connect(map, "onLoad", function () {             this.initUI();           });      }
0 Kudos
JoanneMcGraw
Occasional Contributor III
That's exactly what I needed to do.

Thank you, Kelly!

cheers,
jtm
0 Kudos