Get infoWindow Height and width -

3208
6
03-21-2012 06:50 AM
CliveSwan
Occasional Contributor II
Hi,

I have queried the infoWindows properties, getting an error returned??
addIdentifyResultsToMap (function) error, details: [object error]

Any idea why this returns an error??

widthoftable = document.getElementById(map.infoWindow).width;
heightoftable = document.getElementById(map.infoWindow).height;
alert("Height = " + heightoftable + " \Width = " + widthoftable);
0 Kudos
6 Replies
derekswingley1
Frequent Contributor
The info window has height and width properties you can reference:
map.infoWindow.height
map.infoWindow.width
0 Kudos
CliveSwan
Occasional Contributor II
Hi Derek,

Many thanks for the email.

I modified the code:

                widthoftable = map.infoWindow.width;
                heightoftable = map.infoWindow.height;
                alert("Height = " + heightoftable + " \Width = " + widthoftable);

No error, get mesage Height = undefined Width = undefined.

If the infoWindow has 1 record it maybe 100 px x 200 px. If it has 10 records this maybe 500 px x 200px.
Trying to find the height & width to auto-size the infoWindow.
0 Kudos
derekswingley1
Frequent Contributor
Is your "map" variable a reference to your map?
0 Kudos
CliveSwan
Occasional Contributor II
Hi,

Yes the map is var map;

The infoWindow is defined:
map.infoWindow.setTitle("Identify Results");
map.infoWindow.setContent(tc.domNode);
map.infoWindow.resize(360, 200);

If there is only 1 record returned, then keep the infoWindow (360, 200).
How ever if there is more than 1 record then increase the infoWindow to fill the page.
0 Kudos
CliveSwan
Occasional Contributor II
I tried to edit the TabContainer to increase the size.

else if ( (theLayerName != "Underground") && (idResults.length  > 1) )
                 {
                  // alert("> 1 record");
    map.infoWindow.resize(900, 450);
    new dijit.layout.TabContainer({
                  style : "width:890px;height:300px;visibility:hidden;display:none;padding:2px;",})
                  }
}

Get an error, expected identifies, string or number??
0 Kudos
Mindaugas_ižas
New Contributor
What I did when I needed resize was this:
Put the content in the DIv and then check its height and width.
and then apply it to infowindow (adding some extra pixels for title and so on)
This way you get exact size for example if one line is very long and goes for two lines.
I also would suggest to set maximum height and width so it would not go on all screen 🙂
Hope that helps
0 Kudos