2

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?

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

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.

  • I usually use encodeuricomponent() while passing more complicated CQL filters – Devdatta Tengshe Feb 24 '17 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\' } )

  • 2
    Welcome to GIS SE. Please, add more details in your answer to help the author and others. – aldo_tapia Aug 3 '18 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.

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.