I'm trying to add legendgraphic from a WMS layer with an external SLD file wich is generated dynamicly. The legend is added but the colors from SLD file are all gray. The WMS layer is colored by SLD filters. In legend the filters are gray. enter image description here The code used is:

            document.getElementById("map").style.width = "90%";
            spatii.mergeNewParams({SLD: "<?php echo $identificator; ?>_spatii_pretmp.sld",STYLES: null});
            document.getElementById("legenda").innerHTML = "<img src=\"<?php echo $identificator."_spatii";?>&SLD=<?php echo $identificator; ?>_spatii_pretmp.sld\" />";

            document.getElementById("map").style.width = "100%";


EDIT Here is the LOG section from geoserver:

Request: getLegendGraphic
    Strict = true
    Height = 14
    Width = 14
    Locale = null
    Format = image/png
    Rules = []
    Styles = [StyleImpl[ name=proprietati:ro25858_spatii]]
    FeatureType = null
    Layers = [SimpleFeatureTypeImpl http://proprietati:ro25858_spatii identified extends Feature(geom:geom,id_spatiu:id_spatiu,identificator:identificator,id_cladire:id_cladire,info:info,numar_contract:numar_contract,beneficiar:beneficiar,pret_total:pret_total)]
    Env = {}
    Scale = -1.0
    Transparent = false
    Exceptions = application/vnd.ogc.se_xml
    LegendOptions = {}
    Version = 1.0.0
    Request = GetLegendGraphic
    RawKvp = {EXCEPTIONS=application/vnd.ogc.se_xml, REQUEST=GetLegendGraphic, FORMAT=image/png, VERSION=1.0.0, SERVICE=WMS, WIDTH=14, SLD=, HEIGHT=14, LAYER=proprietati:ro25858_spatii}
    Get = false
    BaseUrl = http://localhost:8000/geoserver/
    RequestCharset = null

EDIT2 Geoserver is getting the data ok in style visualisation. I don't get it. Here is the picture: enter image description here

EDIT3 Still no solution found. As a workaround - I've generated my Legend from with CSS and PHP

  • dould it be that GeoServer is using the default Polygon style for your layer? consult the log file to see what is happening – Ian Turton Feb 15 '16 at 9:10
  • The default style has a green color. Not gray. I thought about that. But it couoldn't be that. I guess – Sasu Andrei Feb 15 '16 at 10:27
  • can you turn logging up to geoserver developer, run the request and paste that section of the log file into the question please – Ian Turton Feb 15 '16 at 10:30
  • I've inserted the log into the question – Sasu Andrei Feb 15 '16 at 10:46
  • is 'proprietati:ro25858_spatii' a generated SLD or the one you uploaded? – Ian Turton Feb 15 '16 at 10:55

Your Answer

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

Browse other questions tagged or ask your own question.