[OpenLayers-Users] SLD for Openlayers. Need some help.
Rahn Hanno (rahn)
rahn at zhaw.ch
Thu Sep 18 04:31:13 EDT 2008
Hello list,
My english ist not very well but I will try it in English. :-)
Perhaps somebody can help me.
I try to use SLD Documents with OpenLayers. I have a WMS Polygon Layer in my page like this:
<div style="width:300; height:300; border:4px ridge silver; position:absolute; top:64; left:485; float:left;margin:4px" id="map2"></div>
<script defer="defer" type="text/javascript">
var options = {
maxExtent: new OpenLayers.Bounds(649990.818704,222409.340625,736164.431296,284821.471875),
//maxResolution: 10000,
//tileSize: new OpenLayers.Size (200,200),
units: 'm',
projection: "EPSG:4149"
};
var map2 = new OpenLayers.Map('map2',options);
var wmsX = new OpenLayers.Layer.WMS("Gemeinden","http://localhost/cgi-bin/mapserv.exe?", {map:"C:/Daten/TestDaten/Map_Dateien/Kanton_ZH_Gemeinden.map",layers:"gemeinden",format:"image/png",EXCEPTIONS:"application/vnd.ogc.se_inimage"},{singleTile: true} );
map2.addLayer(wmsX);
map2.zoomToMaxExtent();
</script>
Now I will use al SLD File to style the map instaed of the original style from the wms. The polygons should have a colour in different categories from an attribut. For this I made a SLD-File "gemsee.sld" like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<sld:UserStyle 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">
<sld:Name>Default Styler</sld:Name>
<sld:Title>Default Styler</sld:Title>
<sld:Abstract/>
<sld:FeatureTypeStyle>
<sld:Name>UNIQUE_VALUE_POLYGONE</sld:Name>
<sld:Title>title</sld:Title>
<sld:Abstract>abstract</sld:Abstract>
<sld:FeatureTypeName>gemsee</sld:FeatureTypeName>
<sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier>
</sld:FeatureTypeStyle>
<sld:FeatureTypeStyle>
<sld:Name>TEXT_LABEL</sld:Name>
<sld:Title>title</sld:Title>
<sld:Abstract>abstract</sld:Abstract>
<sld:FeatureTypeName>Feature</sld:FeatureTypeName>
<sld:SemanticTypeIdentifier>generic:geometry</sld:SemanticTypeIdentifier>
<sld:Rule>
<sld:Name>Default/all others</sld:Name>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsEqualTo>
<ogc:Literal>1</ogc:Literal>
<ogc:Literal>2</ogc:Literal>
</ogc:PropertyIsEqualTo>
<ogc:PropertyIsEqualTo>
<ogc:Literal>1</ogc:Literal>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:And>
</ogc:Filter>
<sld:TextSymbolizer>
<sld:Label>
<ogc:PropertyName>BEZIRKSNAM</ogc:PropertyName>
</sld:Label>
<sld:Font>
<sld:CssParameter name="font-family">
<ogc:Literal>Times New Roman</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="font-size">
<ogc:Literal>11.0</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="font-style">
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="font-weight">
<ogc:Literal>normal</ogc:Literal>
</sld:CssParameter>
</sld:Font>
<sld:LabelPlacement>
<sld:PointPlacement>
<sld:AnchorPoint>
<sld:AnchorPointX>
<ogc:Literal>0.0</ogc:Literal>
</sld:AnchorPointX>
<sld:AnchorPointY>
<ogc:Literal>0.5</ogc:Literal>
</sld:AnchorPointY>
</sld:AnchorPoint>
<sld:Displacement>
<sld:DisplacementX>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementX>
<sld:DisplacementY>
<ogc:Literal>0</ogc:Literal>
</sld:DisplacementY>
</sld:Displacement>
<sld:Rotation>
<ogc:Literal>0</ogc:Literal>
</sld:Rotation>
</sld:PointPlacement>
</sld:LabelPlacement>
<sld:Fill>
<sld:CssParameter name="fill">
<ogc:Literal>#000000</ogc:Literal>
</sld:CssParameter>
<sld:CssParameter name="fill-opacity">
<ogc:Literal>1.0</ogc:Literal>
</sld:CssParameter>
</sld:Fill>
</sld:TextSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
Now I will use this SLD File to style the map. Is this possible? Can perhaps somebody give me some code? Of course I read the examples, but it didn't work. In the Future I will use one SLD for different Layers.
Can somebody help me please? A lot of thanks for you.
Greetings Hanno
------------------------------------------
Hanno Rahn, Dipl.-Ing. (FH) Geoinformatik
ZHAW Zürcher Hochschule für Angewandte Wissenschaften Umwelt und Natürliche Ressourcen
Fachstelle Geoinformatik
Grüental, Postfach CH-8820 Wädenswil
Tel +41 (0)58 934 5592
Fax +41 (0)58 934 5580
hanno.rahn at zhaw.ch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080918/10ffc6c9/attachment.html
More information about the Users
mailing list