You can pass an SLD url via the layer constructor for a WMS layer:
var lyrDSLine = new OpenLayers.Layer.WMS(
"LINESTRING_LAYER",
GeoServerAddress,
{
layers: 'map:myLayer,
format: 'image/png',
'transparent': 'true',
'SLD': "http://<server>/Styles/LINESTRING.xml"
},
{
tileOptions: { maxGetUrlLength: 2048 }
}
);
You can also update the style by serialising a style object and posting it
back to the layer:
//Serialize style to SLD.
var sld_body = new OpenLayers.Format.SLD().write({
namedLayers: [
{
name: 'map:myLayer',
userStyles: [<style object>]
}
]
});
//Pass style to server.
lyrDSLine.mergeNewParams({ SLD_BODY: sld_body });
The maxGetUrlLength setting forces a postback if the SLD_BODY length is
greater than 2048 characters.
Rohan Parkes
From: [email protected]
[mailto:[email protected]] On Behalf Of Eoin Mac
Aoidh
Sent: Thursday, 14 October 2010 1:09 AM
To: [email protected]
Subject: [OpenLayers-Users] possible to give an SLD url as a layer
symbolizer?
Hi list,
I would like to be able to pass in a URL of an SLD to tell a layer how to
style itself.
Something like below, but that code does not work. Any suggestions? is it
even possible?
It seems a waste to define a whole series of symbolizer rules here when they
are already defined in an SLD for the default display of the layer.
Thanks.
Eoin.
mystyle = new OpenLayers.Style("", {rules: [
new OpenLayers.Rule({
title: "myrules",
filter: // specify a subset of
features in the layer
symbolizer: {
url:
"http://eoinmaca.com/fpt/europe/europe.sld"
}
})
]//close rules array
});
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users