[OpenLayers-Users] Changing the style at runtime of the WMS

Robert Sanson SansonR at asurequality.com
Sun Nov 16 15:59:22 EST 2008


Hi Lucas
 
A WMS server only sends back a finished map as a JPEG or PNG. You cannot then modify that image at the client end (OpenLayers). The StyleMap code is there for modifying vectors, such as a GML or WFS layer, where the vectors are actually rendered at the client end (Browser).
 
I believe there is a way to send some styling information to your WMS server (Geoserver) using an XML SLD which is included as part of the GetMap call. Otherwise, you need to set up different layers on your WMS server with different styling, and call the appropriate one via the WMS GetMap calls.
 
Hope that helps,
 
Robert

>>> "Lucas vargas" <eskopinski at gmail.com> 15/11/2008 7:12 a.m. >>>
Hi,

I'm trying with this code:

basic_wms = new OpenLayers.Layer.WMS("topp:world", "http://localhost:8888/geoserver/wms", {
            srs: 'EPSG:4326', transparent: 'true', layers: 'topp:world', styles: '',                
                format: format, tiled: 'true' }, {isBaseLayer: true}, {buffer: 0});               
                
        map.addLayers([basic_wms]);
        map.zoomToMaxExtent();

        var stationStyles = new OpenLayers.StyleMap({ // This is only for stations 
                "default": new OpenLayers.Style({ 
                    fillColor: "#006699", 
                    strokeColor: "#ff9933", 
                    strokeWidth: 2, 
                    fillOpacity: 0.6 
                }), 
                "select": new OpenLayers.Style({ 
                    fillColor: "#006699", 
                    strokeColor: "#ff9933", 
                    strokeWidth: 6, 
                    fillOpacity: 1 
                }) 
            }); 

basic_wms.mergeNewParams({ styles : stationStyles['select']}); 

but does not work: D

Can anybody help me?

Thanks.

Lucas Vargas Eskopinski.





Click here ( https://www.mailcontrol.com/sr/wQw0zmjPoHdJTZGyOCrrhg== ) to report this email as spam.
------------------------------------------------------------------
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.
------------------------------------------------------------------


This message has been scanned for malware by SurfControl plc. www.surfcontrol.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081117/0afb2922/attachment.html


More information about the Users mailing list