[Users] Checkboxes in Tree

Andreas Hocevar ahocevar at opengeo.org
Mon Sep 21 17:09:57 CEST 2009


Hi,

I just realize that the node takes care of setting the baseLayer 
correctly. Then your zoomend handler should just look like this:

map.events.register('zoomend', map, function(e){
     if (map.getZoom() > 6) {
         m5000.setVisibility(true);
     } else {
         m60000.setVisibility(true);
     }
});

Make sure that you use a current trunk checkout of GeoExt, this 
functionality was only added recently.

Regards,
Andreas.

Sascha Müller wrote:
> Hi,
> 
> to work with the 'zoomend' event works fine. Thanks.
> 
> But the radioButtons in the tree don't change their status. It is still
> on layer checked.
> 
> The code is below:
> 
> var m5000 = new OpenLayers.Layer.WMS(
>           "1:5.000", "http://localhost:8081/geoserver/wms",
>           { layers: "HHA:5000_addo"},
>           { isBaseLayer: true
>         });
>         var m60000 = new OpenLayers.Layer.WMS(
>           "1:60.000", "http://localhost:8081/geoserver/wms",
>           { layers: "HHA:60000_addo"},
>           { isBaseLayer: true}
>         );
> 
> map.addLayer(m60000);
> map.addLayer(m5000);
> 
> map.events.register('zoomend', map, function(e){
>     if (map.getZoom() > 6) {
>         map.setBaseLayer(m5000);
>         m5000.setVisibility(true);
>         m60000.setVisibility(false);
>     } else {
>         map.setBaseLayer(m60000);
>         m5000.setVisibility(false);
>         m60000.setVisibility(true);
>     }
> });
> 
> 
> Sascha
> 
> 
> 
>> Sascha Müller wrote:
>>> thanks for your tip with the min-/maxResolution.
>>>
>>> Is there a chance that the baselayers switching automatically from
>>> active to inactive and vice versa?
>>> Dependent from the defined resolution?
>> Not automatically, but you can do that in a listener to the map's
>> zoomend event. Call map.setBaseLayer(...) in addition to
>> layer.setVisibility(...).
>>
>> A completely different approach would be to work with the map option
>> allOverlays: true, and you just create two layer groups in the tree
>> manually.
>>
>> Regards,
>> Andreas.
>>
>>> Sascha
>>>
>>>> Hi,
>>>>
>>>> Sascha Müller wrote:
>>>>> I want to display Baselayers depending from the scale.
>>>>> If I use radioButtons, the user has to change the Baselayer manually.
>>>>> With checkBoxes, every Baselayer can active and I can make it with
>>>>> Sld.
>>>>>
>>>>> So, how can I change the radioButton into checkBoxes in the tree?
>>>>>   
>>>> You cannot, because having multiple base layers visible at a time
>>>> will break things in OpenLayers. One thing you could try: Dont't
>>>> control your base layer visibility by SLD, but by minResolution and
>>>> maxResolution in the layer object.
>>>>
>>>> Regards,
>>>> Andreas.
>>>>
>>>>> Thanks
>>>>>
>>>>> Sascha
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at geoext.org
>>>>> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>>>>>   
>>>>
>>
> 


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list