[OpenLayers-Users] HELP!!! How implement Filter in WMS Layer

Andreas Hocevar ahocevar at opengeo.org
Mon Sep 14 14:32:16 EDT 2009


Hi,

see my suggestions inline.

fsalas wrote:
> thank you Andeas for your help, but I continue with some problems and
> maybe you can be help me again.
>
>    I do it this and nothing
>
>            var bounds = new OpenLayers.Bounds(
>                -85.49711392680179, 19.65266328193469,
>                -73.59119430594814, 23.44530772150158
>            );
>
>            var options = {
>                controls: [],
>                maxExtent: bounds,
>                maxResolution: 0.04650749851895958,
>                projection: "EPSG:4267",
>                units: 'degrees'
>            };
>
>            map = new OpenLayers.Map('map', options);
>
>
>
>             Batimetria = new OpenLayers.Layer.WMS(
>                "Batimetría","http://urano:3128/geoserver/wms",
>                {
>                     layers: 'topp:batimetria'
>                }
>            );
>
>
>           Cuba = new OpenLayers.Layer.WMS(
>             "Cuba","http://urano:3128/geoserver/wms",
>             {
>                   layers: 'topp:cuba',
>                   srs: 'EPSG:4267',

Remove the srs. You have set it on the map already.
>                  styles: 'line',
>                   transparent: 'true',
>                  format: 'image/png'
>             },
>             {
>                 buffer: 0
>              }
>            );
>
>
>  Sennales = new OpenLayers.Layer.WMS(
>  "Señales","http://urano:3128/geoserver/wms",
>  {
>  layers:'topp:sennal',
> sld_body:'%3CStyledLayerDescriptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3Etopp:sennal%3C/Name%3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFeatureTypeStyle%3E%3CRule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/gml%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Etipo%3C/PropertyName%3E%3CLiteral%3EFV%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%3CPointSymbolizer%3E%3CGraphic%3E%3CExternalGraphic%3E%3COnlineResource%20xmlns:xlink=%22http://www.w3.org/1999/xlink%22%20xlink:type=%22simple%22%20xlink:href=%22file:/D:/AppServ/www/SIGANAV/images/FV.gif%22/%3E%3CFormat%3Eimage/gif%3C/Format%3E%3C/ExternalGraphic%3E%3COpacity%3E%3CLiteral%3E1.0%3C/Literal%3E%3C/Opacity%3E%3CSize%3E%3CLiteral%3E20.0%3C/Literal%3E%3C/Size%3E%3CRotation%3E%3CLiteral%3E0.0%3C/Literal%3E%3C/Rotation%3E%3C/Graphic%3E%3C/PointSymbolizer%3E%3C/Rule%3E%3C/FeatureTypeStyle%3E%3C/UserStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E',
>
>  srs:'EPSG:4267',

Remove the srs
>  height:'557',
>  width:'800',
Remove height and width, these are handled by OpenLayers.

>  transparent:'true',
>         format: 'image/png',
>  }

All your layers are configured as base layers, so I bet you only see the
Batimetria layer. Make the layer an overlay by adding

, {isBaseLayer: false}

> );
>
>  map.addLayers([Batimetria,Cuba,Sennales]);
>
> ---------------------------------------------------------------------------------------
>
>
> I do it this and nothing
>
> function CHANGE_SLD_BODY()
> {
>
> var new_sld_body =
> '%3CStyledLayerDescriptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3Etopp:sennal%3C/Name%3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFeatureTypeStyle%3E%3CRule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/gml%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Etipo%3C/PropertyName%3E%3CLiteral%3EFV%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%3CPointSymbolizer%3E%3CGraphic%3E%3CExternalGraphic%3E%3COnlineResource%20xmlns:xlink=%22http://www.w3.org/1999/xlink%22%20xlink:type=%22simple%22%20xlink:href=%22file:/D:/AppServ/www/SIGANAV/images/FV.gif%22/%3E%3CFormat%3Eimage/gif%3C/Format%3E%3C/ExternalGraphic%3E%3COpacity%3E%3CLiteral%3E1.0%3C/Literal%3E%3C/Opacity%3E%3CSize%3E%3CLiteral%3E20.0%3C/Literal%3E%3C/Size%3E%3CRotation%3E%3CLiteral%3E0.0%3C/Literal%3E%3C/Rotation%3E%3C/Graphic%3E%3C/PointSymbolizer%3E%3C/Rule%3E%3C/FeatureTypeStyle%3E%3C/UserStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E';
>
>
>  map.layers[2].mergeNewParams({sld_body : new_sld_body });
>   map.layers[2].redraw();

Remove the redraw() line. mergeNewParams will take care of that.

> }
>
>
> ---------------------------------------------------------------------------------
>
>
>
> however I do it this and is working fine!
>
>
> http://localhost:3128/geoserver/wms?bbox= -86.09240990784447,
> 19.463031059956343,-72.99589832490545,
> 23.6349399434799280&Format=image/png&request=GetMap&width=800&height=250&srs=EPSG:4267&SLD_BODY=%3CStyledLayerDescriptor%20version%3D%221.0.0%22%3E%3CUserLayer%3E%3CName%3Etopp:sennal%3C/Name%3E%3CUserStyle%3E%3CName%3EUserSelection%3C/Name%3E%3CFeatureTypeStyle%3E%3CRule%3E%3CFilter%20xmlns:gml%3D%22http://www.opengis.net/gml%22%3E%3CPropertyIsEqualTo%3E%3CPropertyName%3Etipo%3C/PropertyName%3E%3CLiteral%3EFV%3C/Literal%3E%3C/PropertyIsEqualTo%3E%3C/Filter%3E%3CPointSymbolizer%3E%3CGraphic%3E%3CExternalGraphic%3E%3COnlineResource%20xmlns:xlink=%22http://www.w3.org/1999/xlink%22%20xlink:type=%22simple%22%20xlink:href=%22file:/D:/AppServ/www/SIGANAV/images/FV.gif%22/%3E%3CFormat%3Eimage/gif%3C/Format%3E%3C/ExternalGraphic%3E%3COpacity%3E%3CLiteral%3E1.0%3C/Literal%3E%3C/Opacity%3E%3CSize%3E%3CLiteral%3E20.0%3C/Literal%3E%3C/Size%3E%3CRotation%3E%3CLiteral%3E0.0%3C/Literal%3E%3C/Rotation%3E%3C/Graphic%3E%3C/PointSymbolizer%3E%3C/Rule%3E%3C/FeatureTypeStyle%3E%3C/UserStyle%3E%3C/UserLayer%3E%3C/StyledLayerDescriptor%3E
>
>
>
>
> and only change it the first part
>
> http://localhost:3128/geoserver/wms?bbox= -86.09240990784447,
> 19.463031059956343,-72.99589832490545,
> 23.6349399434799280&Format=image/png&request=GetMap&width=800&height=250&srs=EPSG:4267
>
>
>
>
> Well, I hope that you can be help me

The above is all I can find. I hope it will work after making these changes.

Regards,
Andreas.

-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.





More information about the Users mailing list