[OpenLayers-Users] Styling geoJSON with SLD (ie convert SLD to
stylemap)
Andreas Hocevar
ahocevar at opengeo.org
Tue Oct 18 06:11:24 EDT 2011
Hi,
take a look at the sld.html example (http://openlayers.org/dev/examples/sld.html). An untested snippet to create a vector layer with styles from your SLD could look like this:
var layerName = "myLayer"; // the NamedLayer from your SLD
OpenLayers.Request.GET({
url: "tasmania/sld-tasmania.xml",
success: function(req) {
sld = format.read(req.responseText);
var vector = new OpenLayers.Layer.Vector(layerName, {
styleMap: new OpenLayers.StyleMap(
sld.namedLayers[layerName].userStyles[0];
)
});
map.addLayer(vector);
}
});
Andreas.
On Oct 16, 2011, at 21:57 , Phil Scadden wrote:
> I am moving a vector file from geoserver to local disk (a USB
> implementation using openlayers). In the past I have used used KML and
> extract styles, but I want to use geoJSON (more compact). I have
> perfectly good sld file on geoserver and I note that style.js is
> modelled on SLD. So is there an easy in which I can convert
> an SLD into a style or stylemap object for use with the data from geoJSON?
>
> Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list