<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=iso-8859-1"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Markeringsbobletekst Tegn";
        margin:0cm;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.MarkeringsbobletekstTegn
        {mso-style-name:"Markeringsbobletekst Tegn";
        mso-style-priority:99;
        mso-style-link:Markeringsbobletekst;
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:3.0cm 2.0cm 3.0cm 2.0cm;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=DA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US>I might be approaching this problem the wrong way (then please tell me how to go instead), but this is what I am facing:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Situation:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>I have an ExtJS TreePanel with several groups. Two of the groups contains baselayers, but none of them are selected programmatically. Both groups are collapsed from the beginning.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>OpenLayers sets the first baselayer added to the map as the active baselayer. In my case this baselayer is also the first layer in the first group.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Problem:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>When I (as the user) expand the second group, GeoExt calls the enforceOneVisible method which determines that no baselayer node has been selected and thus helps me by setting the first layer in the second group to the visible layer. BUT the layer is not activated as a baselayer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Solution:<o:p></o:p></span></p><p class=MsoNormal style='margin-bottom:12.0pt'><span lang=EN-US style='font-size:12.0pt;font-family:"Times New Roman","serif"'>In LayerNode.js in the the method enforceOneVisible I would like to suggest that the part<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>// enforce "at least one visible"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>if(checkedCount === 0 && attributes.checked == false) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> layer.setVisibility(true);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>is extended to take into account that we might encounter a base layer which is not active:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>// enforce "at least one visible"<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>if(checkedCount === 0 && attributes.checked == false) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> if(layer.isBaseLayer && layer.map) {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> layer.map.setBaseLayer(layer);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> } else {<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> layer.setVisibility(checked);<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US> }<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>}<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>This is also what is done in the toggleCheck method.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Notes:<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US>Usually we have only had one group containing baselayers. When expanding this group GeoExt just made the baselayer set by OpenLayers visible, which worked fine because it was already the active baselayer.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US>Kind regards, Casper</span><o:p></o:p></p></div></body></html>