1

I have a legend from my map layers. It's adding a color legend for each layer added dynamically.

My problem : When I ask the layer to be hidden in the layer switcher (I don't want to see it there) it's not showing me the legend anymore, even if the layer is visible.

Is there a way that I can keep it out of the layerSwitcher while letting my legend on display? I want to bypass the problem the libray is causing me. If there was a way to hide the layer from the LayerSwitcher of OpenLayers WITHOUT using DisplayInLayerSwitcher: false, it would solve my problem!!!

This is the code of my legend:

//------ Legend Window ---------------------------------------------------------------------------
/*              --> LegendPanel (This GeoExt Panel automatically displays the legend image of the layer if the layer has been added to the map.
 *                                      If this paticular layer has been removed from the map, his legend image will also automatically be removed from the GeoExt Panel.)
 */
function createLegendPanel(){
        return new Ext.Window({
                id: 'legend_panel_extjs',
                header: true,
                title: '<center>' + extjs_gui_east_panel_title + '</center>',

                shadow: false,
                closable:false,

                collapsible: true,
                animCollapse: false,
                cls: 'WindowPanelCls',
                resizable: false,
                //resizeHandles: 'w',
                draggable: false,

                width:(legendMaxWidth+17),
                height:(legendMaxHeight+15),
                plain: true,

                listeners: {
                        show: windowPosition,
                        collapse: windowPosition
                },
                items: [
                        new GeoExt.LegendPanel({
                                id:'extjs_gui_legend_panel_list',
                                map: map,
                                region:'west',
                                layout: 'table',

                                filter: function(record){
                                        if( !(record.getLayer().isBaseLayer) && !(record.getLayer() instanceof OpenLayers.Layer.Vector) ){
                                                return true;
                                        }
                                },

                                defaults: {
                                        showTitle: false,
                                        baseParams: {
                                                format: 'image/png',
                                                lang: lang
                                        }
                                        ,style: '{border-style: ridge;}'
                                }
                        })
                ]
        });
}

Thanks all.

PS: From the GeoExt website: The LegendPanel will include legends for all the layers in the layerStore it is configured with, unless the layer is configured with displayInLayerSwitcher: false, or a layer record has a hideInLegend field with a value of true. Additional filtering can be done by configuring a filter on the LegendPanel.

David Gourde
  • 3,709
  • 2
  • 31
  • 65

0 Answers0