I might be approaching this problem the wrong way (then please tell me how to 
go instead), but this is what I am facing:

 

Situation:

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.

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.

 

Problem:

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.

 

Solution:

In LayerNode.js in the the method enforceOneVisible I would like to suggest 
that the part

// enforce "at least one visible"

if(checkedCount === 0 && attributes.checked == false) {

    layer.setVisibility(true);

}

 

is extended to take into account that we might encounter a base layer which is 
not active:

 

// enforce "at least one visible"

if(checkedCount === 0 && attributes.checked == false) {

    if(layer.isBaseLayer && layer.map) {

        layer.map.setBaseLayer(layer);

    } else {

        layer.setVisibility(checked);

    }

}

 

This is also what is done in the toggleCheck method.

 

Notes:

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.

 

Kind regards, Casper

_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to