简体   繁体   中英

OpenLayers3 - How to redraw or refresh a WMS Layer?

I'm working on a kind-of live map.

From times to times, is necessary to refresh the layer to get the refreshed content (as the page does not reload).

I tried to remove/add the layer again with setInterval but the layer is not added again.

setInterval(function() {
    map.removeLayer(layer);
    map.addLayer(layer);
}, 10000);

There is a way to do this?

I figure out that setting a timeout before the addLayer do the job. It just smells a little bit.

setInterval(function() {
    map.removeLayer(layer);
    setTimeout(function() {
        map.addLayer(layer);
    }, 100);
}, 10000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM