Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [udig-devel] Applying a style to layer from an SLD file

Jonathan Magtalas wrote:
Hi,
Can someone please give some example code of loading a StyleDescriptor from a file then applying the style to a layer of the map? I currently have 3 layers on a map and I want each to have a different style. I'm able to load the different styles from the SLD file using the SLDParser object. The problem comes when I try to apply them to the layers. This is currently being tested within a simple tool. This bit of code gives me problems: getContext().getMapLayers().get(0).getStyleBlackBoard().put(SLDContent.ID,style); I'm not sure if this is the correct way to apply a style to a layer. I'd appreciate if someone could point me in the right direction.
That looks good to me, you can put anything on the style blackboard, as an example in the latest release the WMS Renderer will pay attention to a WMS "named style" (aka a String).

For an example you could look and the DnD code used when dropping an "*.sld" file onto a layer.
Or the code used by the style dialog when apply is called.
Jody


Back to the top