Thanks Ivan, that's just what I was looking for! Works perfectly, as well as with mergeNewParams to have changes take effect dynamically.
charles On Jul 21, 2011, at 12:37 PM, Ivan Grcic wrote: > Hi Charles, > > although wms specs doesnt have filter included, geoserver does support > filtering: > http://docs.geoserver.org/latest/en/user/services/wms/vendor.html#filter > > You just have to write out the filter object, like in this example: > http://openlayers.org/dev/examples/filter.html > ... > var filter_1_1 = new OpenLayers.Format.Filter({version: "1.1.0"}); > var xml = new OpenLayers.Format.XML(); > ... > > var allStreets = new OpenLayers.Layer.WMS( > "All streets", "/geoserver/wms", > { > ... > filter : xml.write(filter_1_0.write(filter)), > ... > ... > > Hope it helps, > > Regards, > Ivan > > > > On Thu, Jul 21, 2011 at 5:49 PM, Charles Galpin <[email protected]> wrote: >> I would like to filter a WMS layer served by geoserver but I can't seem to >> get the filter to work. >> >> For a vector layer I can use the following just fine: >> var layer = new OpenLayers.Layer.Vector("vector layer", { >> ... >> filter: new OpenLayers.Filter.Comparison({ >> type: OpenLayers.Filter.Comparison.EQUAL_TO, >> property: "prop", >> value: "value" >> }) >> }); >> I have tried using this same filter in the params and options blocks of a >> WMS layer. It appears to be ignored in the options, but is not converted to >> a filter in cql or something in the wms request and shows up as [object >> Object] >> var allStreets = new OpenLayers.Layer.WMS( >> "All streets", "/geoserver/wms", >> { >> filter: >> }, >> { >> .. >> } >> ); >> thanks, >> charles >> >> _______________________________________________ >> Users mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/openlayers-users >> > > > > -- > ------------------------------------------------------- > Ivan Grcic > GeoSolutions S.A.S. > Software Engineer > > > Via Poggio alle Viti 1187 > 55054 Massarosa (LU) > Italy > > phone: +39 0584 962313 > fax: +39 0584 962313 > > http://www.geo-solutions.it > http://geo-solutions.blogspot.com/ > http://twitter.com/geosolutions_it > http://www.youtube.com/user/GeoSolutionsIT > > ------------------------------------------------------- _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
