0

I have a WMS service with multiple layers which I am consuming within a single source through Layers Param.

I need to filter features for few layers from the service. I am able to get the updated image with the filters from GeoServer , But the filtered features from the layers are not highlighted and it's difficult to locate the change on a dense map.

Below is my code to filter the features :

var multipleSrc = new ol.source.TileWMS({
    url: url,
    params: {
        'FORMAT': 'image/png',
        'LAYERS': getCommaSeperatedLayersFromHT(), //Ex : "Layer1;Layer2;Layer3;Layer4;Layer5;Layer6;Layer7;Layer8" 
        'TRANSPARENT': 'TRUE',
        'CQL_FILTER': getCommaSeperatedLayersFromCQL() //Ex : "INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;INCLUDE;Key='Value'" 
    },
    serverType: 'geoserver',
    transition: 0,
    transparent: true,
    opacity: 0.5,
});

If I update the CQL_FILTER then the map is again regenerated with the revised filtered criteria.

Is there a way so that I can highlight the filtered features or I can indicate the filtered features in any way so that it's easier to identify them on map.

  • Are you using an unfiltered OpenLayers base layer and a filtered overlay? The simplest way might be to reduce the opacity of the base layer relative to the filtered layer. Using a globalCompositeOperation when rendering the layers would be another option, to gray out or intensify colours codesandbox.io/s/globalcompositeoperation-fktwf (to do more than one layer independently would need OpenLayers 6 which is still in beta), or use ol.source.Raster to achieve a similar effect (but with much more client overhead). – Mike Aug 27 at 14:24
  • can you switch to a different style for the highlighting? – Ian Turton Aug 27 at 15:45
  • @Mike ,My base layer is Bing map and around 15 layers are linked with 1 single source. the overlapping layers boundries are conflicting and CQL_FILTER results image with all layers along with the filters ones as per query. I suppose Opacity will be linked with all layers. – user684805 Aug 27 at 17:52
  • @IanTurton, I have updated styles for few layers in GeoServer SLD, Is there an option to apply some styles specific to filtered options ? – user684805 Aug 27 at 17:53
  • you can specify a style for any layer as required. – Ian Turton Aug 28 at 14:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.