My sld is applying as below

  function cusMap(strSld_body,talukaName,name){
    var query = new OpenLayers.Layer.WMS.Post(name,  
    geoServerURL, {
        LAYERS : 'VP:village_customize',
        sld_body : strSld_body,
        format : 'image/jpeg',
        transparent : 'true'
        unsupportedBrowsers: [],
        isBaseLayer: false,
        yx : {'EPSG:4326' : true}
    } );
  query.mergeNewParams({'CQL_FILTER': "Taluka='"+talukaName+"'"});
  query.mergeNewParams({'sld_body': strSld_body});


But the legend is not coming as per sld made. How can I force legends to show up?

I am using Ext JS Tree to show legends.

 Ext.onReady(function() {

var mapPanel = new GeoExt.MapPanel({
    renderTo : 'mymap',
    region: "center",
    boxMaxWidth : 762,
    boxMaxHeight : 490,
    map: map
    //layout: "fit"       


var tree = new Ext.tree.TreePanel({
    renderTo : 'mytree',
    region: "east",
    title: "Layers / Legends",

    width: 230,
    boxMaxHeight : 455,

    autoScroll: true,
    enableDD: true,
    collapsible: false,
    split: false,

    plugins: [{
            ptype: "gx_treenodecomponent"
    loader: {
        applyLoader: true,
        uiProviders: {
            "custom_ui": LayerNodeUI
    root: {
        nodeType: "gx_layercontainer",
        loader: {
            baseAttrs: {
                uiProvider: "custom_ui"

            createNode: function(attr) {
                // add a WMS legend to each node created
                attr.component = {
                    xtype: "gx_wmslegend",
                    layerRecord: mapPanel.layers.getByLayer(attr.layer),
                    showTitle: false,
                    cls: "legend"
                return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
    rootVisible: false,
    lines: true

new Ext.Viewport({
    layout: 'border',
    region: 'center',
    autoScroll: true,

    split: false,
    renderTo : 'bodypanel',
            items: [




you need to submit an http request using the wms service and a GetLegendGraphic request. Details here. Pass your sld as a SLD_BODY parameter to the request

This should return the image and then you have to replace the one you allready have (I pressume you get the default style you attached to the Geoserver layer) with the one returned on the response.

| improve this answer | |
  • But how to update legend tree which is in ExtJS-tree-legend? – prem30488 Dec 17 '15 at 11:24
  • this is up to you. You dont provide any code about extjs so I dont really know how you do it. I guess you have a method to populate the tree with the images. Is it right? If yes use a new method to update some of them. – pavlos Dec 17 '15 at 11:27
  • I have used javascript as shown in edited question. – prem30488 Dec 17 '15 at 11:32
  • Amigo, this is Geoext it is not pure extjs+ol2. You better mention it within your question as what you ask is specific for Geoext. I could help you out if it was pure extjs+ol2 but I am not familiar with Geoext – pavlos Dec 17 '15 at 11:34
  • Oh.. Thank you very much for your kind support. You helped me a lot. Thank You. I will find some other way of GeoEXT. – prem30488 Dec 17 '15 at 11:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.