I would like to add to my leaflet's web map layer from my WMS service (Geoserver), but I need to use CQL filter in GetMap link:


Is it possible? Please, help ;)


var heatmap = L.tileLayer.wms('http://my_wms_adress:8080/geoserver/my_location/wms?service=WMS&version=1.1.0&request=GetMap&layers=my_location:my_location_history&styles=&bbox=54.406021,18.531216,54.497708,18.577851&width=768&height=390&srs=EPSG:4326&format=application/openlayers&CQL_FILTER=user_id=1', {layers: 'my_location_history', format: 'image/png',transparent: true})

As you can see I added all parameters, but IMHO it's wrong, but I am not sure how to do it. Can I skip parameters like bbox, width, height and add only CQL_FILTER?

  • please add in some of the code you have already tried along with a note of what is not working
    – Ian Turton
    Commented May 3, 2016 at 14:01
  • I've added code above in my post.
    – lomasz
    Commented May 3, 2016 at 14:10
  • Have you tried to add %27 (single quote) on both sides of your id? i.e. CQL_FILTER=user_id=%271%27
    – Barbarossa
    Commented Feb 14, 2017 at 21:58

4 Answers 4


Your code contains:


And I will guess that the two =s are messing up the URL.

In Leaflet WMS tilelayers, any extra options which are not defined will be passed to the WMS server as parameters in each request URL, so:

var layer = L.tileLayer.wms(
        layers: 'my_location_history',
        format: 'image/png',
        transparent: true,
        CQL_FILTER: 'user_id=1'

Note that you do not need to specify the WMS version, request=GetMap or any other standard WMS parameters in the URL template.

Also, do check the Leaflet WMS tutorial.

  • I usually use encodeuricomponent() while passing more complicated CQL filters Commented Feb 24, 2017 at 14:54

var layer = L.tileLayer.wms( 'http://my_wms_adress:8080/geoserver/my_location/wms', { layers: 'my_location_history', format: 'image/png', transparent: true, CQL_FILTER: 'user_id=\'1\' } )

  • 2
    Welcome to GIS SE. Please, add more details in your answer to help the author and others.
    – aldo_tapia
    Commented Aug 3, 2018 at 12:45

If anyone is interested, in ArcMap (10.1), you can add a WMS then go to the params and add the same CQL_FILTER in the properties of the WMS.


As mentioned here

adding &CQL_FILTER=YOUR_FIELD='YourValue' would just make it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.