Openlayers 5.3如何重新加载ImageWMS源以显示来自服务器的更新数据

Openlayers 5.3如何重新加载ImageWMS源以显示来自服务器的更新数据,openlayers,openlayers-5,Openlayers,Openlayers 5,我创建了一个openlayers映射(版本5.3)。我添加了一个ImageLayer,创建了一个ImageWMS源与ArcGis服务器对话。该层显示良好。我现在需要每30秒刷新一次该层 我尝试使用刷新方法,但没有成功。我需要的是源代码重新加载url。但它根本不能做到这一点 我试图在url中添加带有时间戳的参数,但ArcGis根本不喜欢这样 const wms_source = new ImageWMS({ url: 'https://my_secret_domain/arcgi

我创建了一个openlayers映射(版本5.3)。我添加了一个ImageLayer,创建了一个ImageWMS源与ArcGis服务器对话。该层显示良好。我现在需要每30秒刷新一次该层

我尝试使用刷新方法,但没有成功。我需要的是源代码重新加载url。但它根本不能做到这一点

我试图在url中添加带有时间戳的参数,但ArcGis根本不喜欢这样

const wms_source =  new ImageWMS({
        url: 'https://my_secret_domain/arcgis/services/Project/TEST_Lightning/MapServer/WMSServer?request=GetMap',
        projection: 'EPSG:4326',
        styles: 'default',
        params: {
            layers: '0',

        },

    })
    const lightning_layer =  new ImageLayer({


    })
lightning_layer.setSource(wms_source);
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'
        })
    });
// I would expect this to reload the source ...
// but looking into the debugger shows that it is not.
wms_source.refresh

有人知道如何重新加载源代码以显示来自服务器的更新数据吗?

感谢JGH的评论,我找到了需要更改的内容

我没有将timestemp添加到源的初始设置中,但我添加了间隔函数,在该函数中,我每30秒更新一次URL,然后运行刷新

setInterval(() => {
    wms_source.setUrl('https://my_top_secret_domain/Project/TEST_Lightning/MapServer/WMSServer?request=GetMap&TIMESTAMP=' + new Date().getTime());
        this.wms_source.refresh();
    }, 30000); // 30s

现在一切正常了

谢谢你的评论JGH,我试过了,但还是没有改变。如果我更显著地更改URL,比如从https更改为http,那么刷新将重新加载该层。但不是在使用时间戳方法时再次感谢你的评论JGH,你的评论最终帮助了我。他给我指明了正确的方向。