[Geoprisma-dev] LegendPanel and GetLegendGraphic requests

Etienne Dube etienne.dube at boreal-is.com
Thu Oct 14 17:12:12 EDT 2010


  Hi list,

In one of our projects, we noticed an issue with the behavior of the 
LegendPanel widget. This is for a map which has many layers, but only a 
few of them are initially visible. However, we noticed that when the 
LegendPanel widget is added to a workspace, GetLegendGraphic requests 
are issued for every WMS layer, even if these layers are invisible.

Looking at the code, I noticed that the GeoExt LegendPanel takes every 
layer in the Map widget and creates LayerLegend objects, whatever the 
visibility of the layer is. These LayerLegend (in occurrence WMSLayer 
objects) for invisible layers are added as invisible divs in the legend 
panel, with the src of the contained img element pointing to the 
GetLegendGraphic URL for the layer. So in effect, these images are 
loaded from the server even if they're not displayed, which is far from 
optimal.

Any idea for what would be the best way to change this behavior? I can 
suggest two possibilities:

- What about a GeoExt-based LayerTree? It could manage its own store for 
visible layers, and the LegendPanel could attach to this store in order 
to manage only LayerLegend objects for layers that are really visible. 
However I don't know enough about GeoExt to say if it's easy to do.

- We could modify or subclass LegendPanel, so that it instanciates 
LayerLegend objects only for visible layers. The handler for update 
events on the layer store (which is triggered when a layer changes 
visibility) would have to add/remove LayerLegends depending on the 
visibility status of each layer.

Thanks,

Etienne


-- 
Etienne Dubé
Consultant / Développeur

Boréal Informations Stratégiques
101, Du Moulin, bureau 202-A
Magog (Québec)
J1X 4A1

Tel. :  514.313.5951 #1131
Courriel: etienne.dube at boreal-is.com




More information about the Geoprisma-dev mailing list