I am trying to recreate the ArcGIS Javascript API/Dojo ContentPane layout template shown here for my own custom application. I would like to switch from using dojo.require() legacy syntax to using AMD module require syntax.
Here is how I have structured my Javascript (removed everything but the basemap from the ArcGIS template):
<script>
var map;
require([
"dijit/layout/BorderContainer",
"dijit/layout/ContentPane",
"esri/map",
"dijit/layout/TabContainer",
"esri/dijit/Legend"
], function(
BorderContainer,
ContentPane,
Map,
TabContainer,
Legend
){
map = new esri.Map("map", {
center: [-85.772, 38.255],
zoom: 10,
basemap: "satellite"
});
});
</script>
I didn't change much about the HTML except for changing the periods to slashes consistent with the AMD syntax:
<body class="claro">
<div id="mainWindow" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="design:'headline', gutters:false" style="width:100%; height:100%;">
<div id="header" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'top'">
This is the header section
<div id="subheader">subheader</div>
</div>
<div data-dojo-type="dijit/layout/ContentPane" id="leftPane" data-dojo-props="region:'left'">
<div data-dojo-type="dijit/layout/TabContainer">
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Legend', selected:true">
<div id="legendDiv"></div>
</div>
<div data-dojo-type="dijit/layout/ContentPane" data-dojo-props="title:'Tab 2'" >
Content for the second tab
</div>
</div>
</div>
<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'"></div>
<div id="footer" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'bottom'">
this is the footer section
</div>
</div>
</body>
Making this switch has caused a very annoying problem in which the actual map typically only fills half of its ContentPane when the page initially loads. This problem can usually be fixed by resizing the window.
I'm aware that esri/Map objects are typically instantiated to the size of their parent container. I am not well versed in the nitty-gritty of asynchronous Javascript, but the fact that this is happening makes me wonder if the ContentPane and Map are loading independently of each other and the Map isn't getting the size info of the ContentPane.
Is this what's happening?
If so, how can I avoid having to resize the window to get the map to fill the ContentPane?