[Users] refresh LayerLegend after redraw wfs layer

Julien-Samuel Lacroix jlacroix at mapgears.com
Wed Aug 14 22:17:15 CEST 2013


Hi,

I don't think there's an out of the box way to do this, but you can do 
the following:

- Get the VectorLegend object from your LegendPanel
- reset the rules with setRules()
- update the panel item with update()

Go here
http://dev.geoext.org/geoext/trunk/geoext/examples/legendpanel.html
and paste the following code in a console:

// Modify the layer's style
mapPanel.map.layers[2].styleMap.styles.default.defaultStyle.fillColor = 
"#ff0000";
mapPanel.map.layers[2].redraw();

// Update the LegendPanel
for(i=0; i<legendPanel.items.items.length; i++) {
     // Note: 'Polygons' is the layer name
     if(legendPanel.items.items[i].layer.name == 'Polygons') {
         legendPanel.items.items[i].setRules();
         legendPanel.items.items[i].update()
         break;
     }
}

Best regards,
Julien


On 13-08-14 03:38 PM, Jorge Alejandro Vergara wrote:
> I need to use in my app, the option to change the default legend for some of my layers.
>
> I change the style of my vectorlayer with internal openlayers rule and works ok, but after this,
>
> i need to view the new style reflected in the legend and i have not found a solution so far.
>
> I have worked with geoext for a couple of months, so any help wiill be appreciated
>
>
> I am using the LegendPanel object from geoext 1.1
>
>
> Any suggestions?
>
> thanks in advance
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
>

-- 
Julien-Samuel Lacroix
Mapgears
http://www.mapgears.com/


More information about the Users mailing list