1

I am trying to create an SLD dynamically using parameters accepted from user. So how could I accomplish the task of adding the dynamically created SLD to my map layer?

Please tell me how to add style to layer dynamically, I am using GXP, OpenLayers, GeoEXT, GeoServer.

1

There are several options here:

  1. use GeoServer's REST API to upload the SLD you create and then reference it in the WMS request (as a named style), this is what GXP does (try and edit a style with GeoExplorer and see what XHR traffic goes on) see for instance: https://github.com/boundlessgeo/gxp/blob/master/src/script/plugins/GeoServerStyleWriter.js

  2. if your SLD is small, you can also just append it with SLD_BODY to the WMS request (mind the length of your GET request here), this is what is done here: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Control/SLDSelect.js OpenLayers also has an iframe image tile class that allows you to use POST: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Tile/Image/IFrame.js

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.