[Users] Show user defined styles in GeoExt.LegendPanel?

Eoin Mac Aoidh eoinyp at yahoo.com
Wed Dec 15 10:53:25 CET 2010


Hi all,
Is it possible to show non-Geoserver defined styles in the LegendPanel? (sld file is non existent)
For a layer straight out of Geoserver this is no problem, I understand the corresponding sld is consulted to define the entry in the lgend.
I have a query facility where the user specifies on the fly which attributes he would like to see in a given layer, and how he would like them styled (color, radius etc.).
The layers display fine on the map and in the layer tree, but I would like to add a corresponding entry in the legend panel. At present only the layerName shows, but no icon(s).
Some code extracts are included below.
Any tips or hints would be gratefully received,
Thanks,
Eoin

An extract from the code used to specify the style parameters for the layer is as follows:

 queryLayer.mergeNewParams({
                            sld_body: new OpenLayers.Format.SLD().write({
                                namedLayers: [{
                                    name: panel.selectedLayer.get("name"), 
                                    userStyles: [style]  
                                }]
                            })
                        });
 map.addLayer(queryLayer);

The user's style is constructed as follows:

style = new OpenLayers.Style("", {rules: [
                            new OpenLayers.Rule({
                                    title: "generic point rule",
                                 filter: panel.getFilter(),  //append the criteria specified by the user (attributes + their values)
                                 symbolizer: {
                                              "Point": {
                                                        pointRadius: hilightsize, // user defined
                                                        graphicName: "circle",
                                                        fillColor: hilightcolor, // user defined
                                                        fillOpacity: 0.75,
                                                        strokeWidth: 1,
                                                        strokeOpacity: 0.75,
                                                        strokeColor: "#000000"
                                                        }
                                               }
                                })
                                ]//close rules array
                            }); //close var definition 



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20101215/d0151551/attachment.htm 


More information about the Users mailing list