0

Tell me, please, how I can apply cql_filter, based on currently map location in leaflet.js.

I have following code:

var myLayer = L.tileLayer.wms("url-to-geoserver", 
{
    layers: 'heatmap:layer',
    format: 'image/png',
    transparent: true,

});

and I need to apply (on each map ondragstop event I guess) cql filter like this: (geom+IS+NOT+NULL+AND+l_room+IS+NOT+NULL+AND+BBOX(geom,55.46187404873886,37.52260208129883,55.46845504793832,37.56232023239136)).

Help me with this, please, or give some keywords for further googling.

1

You need to pass a parameter called cql_filter to geoserver so just add it to the layer options.

var myLayer = L.tileLayer.wms("url-to-geoserver", 
{
    layers: 'heatmap:layer',
    format: 'image/png',
    transparent: true,
    cql_filter: '(geom+IS+NOT+NULL+AND+l_room+IS+NOT+NULL+AND+BBOX(geom,55.46187404873886,37.52260208129883,55.46845504793832,37.56232023239136))'
});

However WMS will automatically filter by the bounding box and ignore geometries that are null so you should be able to simplify that to l_room+IS+NOT+NULL.

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.