[OpenLayers-Users] mergeNewParams + Legend

Andreas Hocevar ahocevar at opengeo.org
Thu Aug 5 11:57:55 EDT 2010


Hi,

I am pretty sure that the request URI is too long. What you could do is reconfigure the legend type selection sequence, so a VectorLegend rather than a WMSLegend is created. A prerequisite is this non-API hack though:

GeoExt.VectorLegend.supports = function(layerRecord) {
    return layerRecord.get("layer").styleMap;
};

This will tell VectorLegend that it supports all layers that have a styleMap.

Now you can go ahead and create your legendPanel like this:

var legendPanel = new GeoExt.LegendPanel({
    preferredTypes: ["gx_vectorlegend"]
});

Finally, when creating your WMS layer with the SLD_BODY (and before you do mergeNewParams), you have to give the WMS layer a StyleMap with a "default" render intent, which you have to give the style object of your SLD.

Regards,
Andreas.

On Aug 5, 2010, at 17:45 , Sascha Müller wrote:

> 
> 
> Hi,
> 
> I tried this SLD with only two instead of five rules. It works.
> Could it be, that the request 'GetLegendGraphic' is too long with the 
> SLD inside?
> Like mergeNewParams() without 'Post'  in 'OpenLayers.Layer.WMS'.
> 
> Is there a way to implement it?
> Or is this more a GeoServer thing?
> 
> Sascha
> 
> 
>> 
>> Hi,
>> 
>> I use:
>> 
>> GeoExt: trunk (Revision: 2257)
>> OpenLayers: 2.9
>> GeoExt: 3.2.1
>> GeoServer: 1.7.7
>> 
>> 
>> I use mergeNewParams() to change the Style of a layer. This approach
>> works except for one layer.
>> This layer contains five rules with filter. The map changes after
>> mergeNewParams(), the legend not.
>> The layername is still there, the images of the five rules are gone.
>> 
>> If I use this SLD (see below) for the layer with the GeoServer from
>> start, the layer appears in map and legend. only after
>> mergenewParams() the layer appears not in the legend.
>> 
>> The layer uses this:  var addlayer = new OpenLayers.Layer.WMS.Post()
>> 
>> SLD
>> ===
>> <?xml version="1.0" encoding="UTF-8"?>
>> <sld:StyledLayerDescriptor xmlns="http://www.opengis.net/sld"
>> xmlns:sld="http://www.opengis.net/sld"
>> xmlns:ogc="http://www.opengis.net/ogc"
>> xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
>> <sld:NamedLayer>
>> <Name>WL:UBahn</Name>
>> <sld:UserStyle>
>> <sld:Name>Default Styler</sld:Name>
>> <sld:Title/>
>> <sld:FeatureTypeStyle>
>> <sld:Name>name</sld:Name>
>> <sld:FeatureTypeName>Feature</sld:FeatureTypeName>
>> <sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier>
>> <sld:SemanticTypeIdentifier>colorbrewer:unique:oranges</sld:SemanticTypeIdentifier>
>> <sld:Rule>
>> <sld:MinScaleDenominator>0</sld:MinScaleDenominator>
>> <sld:MaxScaleDenominator>100000000</sld:MaxScaleDenominator>
>> <sld:Name>rule01</sld:Name>
>> <sld:Title>U1</sld:Title>
>> <Filter>
>> <PropertyIsEqualTo>
>> <PropertyName>LINIE</PropertyName>
>> <Literal>U1</Literal>
>> </PropertyIsEqualTo>
>> </Filter>
>> <sld:LineSymbolizer>
>> <sld:Stroke>
>> <sld:CssParameter name="stroke">
>> <Literal>#FEEDDE</Literal>
>> </sld:CssParameter>
>> <sld:CssParameter name="stroke-linecap">
>> <Literal>butt</Literal>
>> </sld:CssParameter>
>> <sld:CssParameter name="stroke-linejoin">
>> <Literal>miter</Literal>
>> </sld:CssParameter>
>> <sld:CssParameter name="stroke-opacity">1</sld:CssParameter>
>> <sld:CssParameter name="stroke-width">3</sld:CssParameter>
>> <sld:CssParameter name="stroke-dashoffset">
>> <Literal>0</Literal>
>> </sld:CssParameter>
>> </sld:Stroke>
>> </sld:LineSymbolizer>
>> </sld:Rule>
>> 
>> <!-- The other RULSs looks the same like the one above -->
>> 
>> </sld:FeatureTypeStyle>
>> </sld:UserStyle>
>> </sld:NamedLayer>
>> </sld:StyledLayerDescriptor>
>> 
>> Is there something wrong with the SLD? Do I have something to consider
>> if I use mergeNewParams(), or something with the Legend?
>> 
>> Thanks
>> 
>> Sascha
>> 
>> 
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>> 
>> 
>> 
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list