マップ レイヤーの凡例があります。動的に追加された各レイヤーの色の凡例を追加しています。
私の問題:レイヤースイッチャーでレイヤーを非表示にするように依頼すると(そこに表示したくない)、レイヤーが表示されていても、凡例が表示されなくなります。
凡例を表示しながら、layerSwitcher から除外する方法はありますか? ライブラリが引き起こしている問題を回避したい。DisplayInLayerSwitcher: false を使用せずに OpenLayers の LayerSwitcher からレイヤーを非表示にする方法があれば、私の問題は解決します!!!
これは私の伝説のコードです:
//------ 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;}'
}
})
]
});
}
皆さんありがとう。
PS: GeoExt Web サイトから: LegendPanel には、レイヤーが displayInLayerSwitcher: false で構成されていない限り、またはレイヤー レコードに true の値を持つ hideInLegend フィールドがない限り、構成されている layerStore 内のすべてのレイヤーの凡例が含まれます。LegendPanel でフィルターを構成することにより、追加のフィルター処理を行うことができます。