Select to view content in your preferred language

different Map behavior in 3.4 between "require" and AMD style loading

1547
10
04-02-2013 05:01 PM
JohnCartwright
Deactivated User
Hello All,

I'm using v3.4 and finding some differences in the Map behavior when using the older "require" style module loading and the newer AMD style.  I'm using a BorderContainer with the map in the center panel and finding that w/ AMD, I have to explicitly call map.resize() to get it to fill the panel.  Also, w/ AMD the "center" property of a Map doesn't seem to have any effect. Listed below are two examples that I'd expected to provide identical results, but don't.  I assume it has something to do w/ the timing of the module load, but I'm not clear on what to do differently.

Thanks for any help!

--john

//works OK
function initMap() {
    map = new esri.Map("map", {
       basemap: "oceans",
       center: [-102, 40],
       zoom: 5
 }); 


require(["esri/map"],
   function(Map) {
      var map = new Map("map", {
         basemap: "oceans",
         center: [-102, 40],  //does not seem to be respected
         zoom: 5});

   //not sure why this seems to be required w/ AMD loaded module
   map.resize();
});
0 Kudos
10 Replies
derekswingley1
Deactivated User
Jason,

Try this:  http://jsfiddle.net/NST5v/

Use dojo/ready to ensure that all modules have loaded and instead of parseOnLoad: true, manually call the parser.

More info on dojo/domReady vs. dojo/ready:  http://www.sitepen.com/blog/2013/04/17/dojodomready-vs-dojoready/
0 Kudos