How to "reset" the map's infoWindow size so that it auto-sizes itself?

3747
3
Jump to solution
12-06-2012 02:10 PM
StephenLead
Regular Contributor III
Click on a feature in the Popup sample, and note that the map's infoWindow automatically displays at the optimal size for its content.

It is possible to override this size using map.infoWindow.resize(500,500) - thereafter, the infoWindow always opens at this size when clicking on new features.

How can I "reset" the size so that the infoWindow automatically resizes to fit its content once more, after I've used map.infoWindow.resize()? In other words, how can I "undo" the resize command without specifying a new size?

Background - I have a multi-layer map and I'm manually resizing the infoWindow to suit a particular layer's infoWindow, but I wish for the infoWindow to return to normal auto-sizing behaviour when clicking on other layers.

Thanks,
Steve
0 Kudos
1 Solution

Accepted Solutions
WyattPearsall
New Contributor II
You wouldn't be too far amiss adding styles through CSS to the esriPopup class and its children. You could also first create an empty div of height 500px, width 500px that you set as the content of the infowindow, then set the content of that div as your data. Doing this in a callback for a successful request for data should be fairly seamless.

View solution in original post

0 Kudos
3 Replies
WyattPearsall
New Contributor II
You wouldn't be too far amiss adding styles through CSS to the esriPopup class and its children. You could also first create an empty div of height 500px, width 500px that you set as the content of the infowindow, then set the content of that div as your data. Doing this in a callback for a successful request for data should be fairly seamless.
0 Kudos
StephenLead
Regular Contributor III
Bingo. I used a much simpler version of your suggestion to "reset" the size after showing a large infoWindow:

dojo.connect(map.infoWindow, "onHide", function () {
    map.infoWindow.setContent("");
});


Thanks,
Steve

EDIT: This doesn't actually work. I'll keep working on it but I think your suggestion is on the right track
0 Kudos
Tecnologia__Logística_i_Qualit
New Contributor

Probably is an old question and not interesting for many people, but if everyone has a similar problem, I've found a solution to 'undo' resize method for infoWindow.

Try this (javascript code) at onHide event for infoWindow:

try {

      map.infoWindow.setContent(' ');

      dojo.style(map.infoWindow._contentPane,'max-height','');

      dojo.forEach(map.infoWindow._sizers,function(o){dojo.style(o,'width','');});

    } catch(e) {}

Live Long and Prosper