<P>Ok. After *A LOT* of troubleshooting and Googling and trial-and-error, I figured out that defining certain attributes (copied from other example) was causing the problem. Namely, "Name" and "Title", as well as the "ogc:Or" tags.</P>
<P>So, I have part of my problem solved. The following works for coloring some of the polygons red and the rest yellow.</P>
<PRE>
<BLOCKQUOTE>
var sld = '<StyledLayerDescriptor version="1.0.0"';
sld += ' xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" ';
sld += ' xmlns="http://www.opengis.net/sld" ';
sld += ' xmlns:ogc="http://www.opengis.net/ogc" ';
sld += ' xmlns:xlink="http://www.w3.org/1999/xlink" ';
sld += ' xmlns:xsi="http://www.w3.org/2001/<MLSchema-instance"&gt;';
sld += ' &lt;NamedLayer&gt;';
sld += ' &lt;Name&gt;MyStore:MyLayer&lt;/Name&gt;';
sld += ' &lt;UserStyle&gt;';
<DEL></DEL>
<DEL>sld += ' <Title>Colored Polygon</Title>';</DEL>
<DEL>sld += ' <Name>Colored Polygon</Name>'; </DEL>
sld += ' <FeatureTypeStyle>';
sld += ' <Rule>';
sld += ' <ogc:Filter>';
<DEL>sld += ' <ogc:Or>';</DEL>
sld += ' <ogc:FeatureId fid="MyLayer.1" />';
sld += ' <ogc:FeatureId fid="MyLayer.2" />';
sld += ' <ogc:FeatureId fid="MyLayer.3" />';
<DEL>sld += ' </ogc:Or>';</DEL>
sld += ' </ogc:Filter>';
sld += ' <PolygonSymbolizer>';
sld += ' <Fill>';
sld += ' <CssParameter name="fill">#FF0000</CssParameter>';
sld += ' <CssParameter name="fill-opacity">0.5</CssParameter>';
sld += ' </Fill>';
sld += ' <Stroke>';
sld += ' <CssParameter name="stroke">#800000</CssParameter>';
sld += ' <CssParameter name="stroke-width">2</CssParameter>';
sld += ' </Stroke>';
sld += ' </PolygonSymbolizer>';
sld += ' </Rule>';
sld += ' <Rule>';
<SPAN style="BACKGROUND-COLOR: #ffff00">sld += '<ElseFilter/>';</SPAN>
<DEL>sld += ' <ogc:Filter>';</DEL>
<DEL>sld += ' <ogc:Not>';</DEL>
<DEL>sld += ' <ogc:Or>';</DEL>
<DEL>sld += ' <ogc:FeatureId fid="MyLayer.1" />';</DEL>
<DEL>sld += ' <ogc:FeatureId fid="MyLayer.2" />';</DEL>
<DEL>sld += ' <ogc:FeatureId fid="MyLayer.3" />';</DEL>
<DEL>sld += ' </ogc:Or>';</DEL>
<DEL>sld += ' </ogc:Not>';</DEL>
<DEL>sld += ' </ogc:Filter>';</DEL>
sld += ' <PolygonSymbolizer>';
sld += ' <Fill>';
sld += ' <CssParameter name="fill">#FFFF00</CssParameter>';
sld += ' <CssParameter name="fill-opacity">0.5</CssParameter>';
sld += ' </Fill>';
sld += ' <Stroke>';
sld += ' <CssParameter name="stroke">#CCCC00</CssParameter>';
sld += ' <CssParameter name="stroke-width">2</CssParameter>';
sld += ' </Stroke>';
sld += ' </PolygonSymbolizer>';
sld += ' </Rule>';
sld += ' </FeatureTypeStyle>';
sld += ' </UserStyle>';
sld += ' </NamedLayer>';
sld += '</StyledLayerDescriptor>';
coloredLayer = new OpenLayers.Layer.WMS(
"Polygons-Room", "http://localhost:8081/geoserver/wms",
{
layers: "MyStore:MyLayer",
transparent: true,
format: 'image/png',
sld_body: sld
},
{
singleTile: true,
ratio: 1,
isBaseLayer: false
}
);
</BLOCKQUOTE>
</PRE>
<P>I would like to know how to write the rule for coloring some polygons red, some blue, some green, and the rest yellow. Is this possible? I have tried different permutations of the "Or". I have tried to have more than one "ElseFilter". I have tried to separate the rules by FeatureTypeStyle. None of which have worked.</P>
<P>Any help with this would be greatly appreciated. I would settle for a decent SLD resource. The cookbook has only basic examples and not even the spec has anything remotely sophisticated as multiple polygon rules. I have only seen a multiple rule with line, polygon, and point. It seems that the OpenLayers.js errs when combining multiple polygon rules.</P>
<P>Sincerely,</P>
<P>Ivan</P>
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/WMS-polygon-fill-color-tp6374589p6376411.html">Re: AW: [OpenLayers-Users] WMS polygon fill color</a><br/>
Sent from the <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Users-f1822463.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br/>