5

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:

localhost/geoserver/my_location/wms?(...)&CQL_FILTER=[...]

Is it possible? Please, help ;)

edit:

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?

3
  • please add in some of the code you have already tried along with a note of what is not working Commented May 3, 2016 at 14:01
  • I've added code above in my post. 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 Commented Feb 14, 2017 at 21:58

4 Answers 4

7

Your code contains:

&CQL_FILTER=user_id=1

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(
    'http://my_wms_adress:8080/geoserver/my_location/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.

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

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\' } )

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

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.

0

As mentioned here

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.