Solved! Go to Solution.
Samir, I have had problems with positioning and resizing. Basically the trick is to figure out when to call map.resize() and map.reposition(). For example if you load the map with Firebug open and then close firebug if you were to use the draw tool you would find that it is offset from your mouse. Is the kind of problem you are having?
Here is my fix. I usually use some combination of these events on most maps. If anyone has a better way, I would love to hear it.
Putting you map in a dijit.layout.ContentPane might help too, but there was a reason I stopped doing that. Possibly, some side effect from being inside a TabContainer I think (can't remember)//resize the map when the browser resizes dojo.connect(this.map, 'resize', this, function(extent) { this.map.reposition(); }); //resize map when a user pans or zooms (sometimes good if you can't initially position and resize the map) dojo.connect(this.map, 'onExtentChange', this, function(extent) { this.map.resize(); this.map.reposition(); }); //dont use this in TabContainer or StackContainer or a Floating Container (Dialog) dojo.connect(this.map, 'onReposition', this, function(x,y) { this.map.resize(); }); //redo sizing when mouse wheel used (i did this because i was getting weird results when a user INITIALLY zoomed into a map using the wheel) dojo.connect(this.map, 'onMouseWheel', this, function(event) { this.map.resize(); this.map.reposition(); }); //redo sizing after first map layer is loaded dojo.connect(this.map, 'onLoad', this, function() { this.map.resize(); this.map.reposition(); });
In Html
<div id="projectTabContainer" dojoType="dijit.layout.TabContainer" style="width: inherit; height: 900px;">
<div id="mappingTab" dojoType="dijit.layout.ContentPane" title="Mapping">
<div id="mapM" dojotype="dijit.layout.ContentPane" region="center"></div>
</div>
<div id="analysisTab" dojoType="dijit.layout.ContentPane" title="Analysis" >
<div id="mapA" dojotype="dijit.layout.ContentPane" ></div>
</div>
I've fiddled around with dojo's content panes and I'm pretty sure that
need to be defined a region where they are supposed to be located (top, left, center, right & bottom).
BTW, can a width be inherited from a parent style that easily with just style="width: inherit;"?
//resize the map when the browser resizes dojo.connect(this.map, 'resize', this, function(extent) { this.map.reposition(); }); //resize map when a user pans or zooms (sometimes good if you can't initially position and resize the map) dojo.connect(this.map, 'onExtentChange', this, function(extent) { this.map.resize(); this.map.reposition(); }); //dont use this in TabContainer or StackContainer or a Floating Container (Dialog) dojo.connect(this.map, 'onReposition', this, function(x,y) { this.map.resize(); }); //redo sizing when mouse wheel used (i did this because i was getting weird results when a user INITIALLY zoomed into a map using the wheel) dojo.connect(this.map, 'onMouseWheel', this, function(event) { this.map.resize(); this.map.reposition(); }); //redo sizing after first map layer is loaded dojo.connect(this.map, 'onLoad', this, function() { this.map.resize(); this.map.reposition(); });
Samir, I have had problems with positioning and resizing. Basically the trick is to figure out when to call map.resize() and map.reposition(). For example if you load the map with Firebug open and then close firebug if you were to use the draw tool you would find that it is offset from your mouse. Is the kind of problem you are having?
Here is my fix. I usually use some combination of these events on most maps. If anyone has a better way, I would love to hear it.
Putting you map in a dijit.layout.ContentPane might help too, but there was a reason I stopped doing that. Possibly, some side effect from being inside a TabContainer I think (can't remember)//resize the map when the browser resizes dojo.connect(this.map, 'resize', this, function(extent) { this.map.reposition(); }); //resize map when a user pans or zooms (sometimes good if you can't initially position and resize the map) dojo.connect(this.map, 'onExtentChange', this, function(extent) { this.map.resize(); this.map.reposition(); }); //dont use this in TabContainer or StackContainer or a Floating Container (Dialog) dojo.connect(this.map, 'onReposition', this, function(x,y) { this.map.resize(); }); //redo sizing when mouse wheel used (i did this because i was getting weird results when a user INITIALLY zoomed into a map using the wheel) dojo.connect(this.map, 'onMouseWheel', this, function(event) { this.map.resize(); this.map.reposition(); }); //redo sizing after first map layer is loaded dojo.connect(this.map, 'onLoad', this, function() { this.map.resize(); this.map.reposition(); });