I need to filter the WMS layer included in my map for a date field. Basically I only want to show what has happened after a certain date:

I tried the following, but no luck

createMap = () => {

    const vectorSource = new VectorSource();

    const vectorLayer = new VectorLayer({
        source: vectorSource

    const baseLayer = new TileLayer({
        source: new OSM()

    this.wms_source = new ImageWMS({
        url: environment.live_lightning_data,
        projection: 'EPSG:4326',
        styles: 'default',
        params: {
            layers: '0'

    const lightning_layer = new ImageLayer({});
    this.map = new Map({
        layers: [baseLayer, lightning_layer],
        target: document.getElementById('lightning'),
        view: new View({
            center: fromLonLat([175.79, -37.79]),
            zoom: 7,
            projection: 'EPSG:3857'

    lightning_layer.filter.greaterThan('data_date_time', '2019/03/02');

I know, a little chaotic, but the map map itself displays the data correctly, but it is unhappy with however I try to add the filer.

The way I added it now,results in '... is not a function'

Anyone any suggestions?

  • 1
    Please provide full error message. – TomazicM Apr 24 at 6:37
  • What if you add TIME: 'your-time' as one of the params ? – nmtoken Apr 24 at 6:39
  • Not sure how you can filter an image (the result of the WMS GetMap request); you need to ask the service for the data, using the appropriate request params. – nmtoken Apr 26 at 9:37

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.