So, I have a geoserver layer with point markers (POI) in several category such as ATMs, churches, government buildings, parks, etc. Is there a way to filter this layer via URL parameters so I don't have to define a new layer for each category? also, I am using openlayers-3 as the frontend interface.

To complete the question, I have a request URL like this:


with the result similar to this: enter image description here

where each of category is saved as category in postgis table_location. Now I want to filter based on category, for example I want to use filter to only show police stations

  • openlayers 2 like the tag, or openlayers 3 like the question? – BradHards Aug 23 '16 at 7:33
  • This is what WFS CQL/ECQL queries do. Have you looked at the filter options in docs.geoserver.org/latest/en/user/filter/syntax.html ? – BradHards Aug 23 '16 at 7:36
  • CMIIW, as long as my understanding, what CQL do in geoserver is creating a query from available layer, and save it as new layer. so, if I have 20 categories, it will create 20 new layers that I can use later. What I am asking is, is there a way to filter from Url without defining a new layer. I read the documentation, but all of example there is confusing for a beginner like me and does not fit to my case. – Zuzu Softman Aug 23 '16 at 7:56
  • 1
    You don't need to create a layer, and normally wouldn't. You can pass the filter as a vendor argument in the WMS URL, or as the filter in WFS. If you show an example of your URL, and the filter you want to use, I might have a chance to provide an answer. – BradHards Aug 23 '16 at 8:05
  • I edited the question – Zuzu Softman Aug 23 '16 at 8:30

CQL_FILTER is documented in http://docs.geoserver.org/stable/en/user/tutorials/cql/cql_tutorial.html.

Make a test request without CQL_FILTER


enter image description here

Make a new request with CQL_FILTER


enter image description here

All you need to do is to make sure that your OpenLayers application adds a CQL_FILTER that fulfills your needs.

  • I see... I can directly input cql in preview and see the difference in requested URL. thank you :) – Zuzu Softman Aug 24 '16 at 7:21

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.