How to update WMS layer?

I'm currently working on an app displaying data from a WMS. The data of the source is frequently updated, and therefore the layer needs to be updated as well. However, the viewport only issues new requests when the map is either zoomed or panned.

What is the best way to force the viewport to re-request and redraw the WMS layer?

BTW: I'm currently using Cesium 1.49.

There is a time property for WMTS that you can use for that:

I don’t think it’s implemented for WMS, but I believe it uses TimeDynamicImagery under the hood, so you could look into that:

I was going to suggest you could try implementing it yourself but it looks like there’s an open pull request for it!

You could use the code from there, or wait until it’s merged into CesiumJS.


meanwhile the pull requests has been merged and a new version is released. I tried to implement it, but I do not really understand how it is supposed to work.

I have no time line, no time interval. I simply want the layer to reload the images say every 10 seconds, as long as the page is open.

Any hints?

Okay, I'm not one step further: the layer now reloads the data every few seconds. But the layer issues several requests for different resolutions. And even worse: The different resolutions are displayed. So on every update, the image is first replaced with some scaled, blurred image of an overview scale, aber soon afterwards the correct image appears.

Is it possible to stop this and only request the most appropriate resolution depending of the zoom level?

You should be in control of that if you’re implementing your own custom imagery provider. I can’t tell why it’s happening without seeing your implementation.

I still think it might be easier to use WMS-T that’s already implemented. Have you taken a look at this Sandcastle example to see how it works?

I checked it, and this example behaves in the same way: When a reload is triggered, every zoom level from the top most level 0 up to the current zoom level is downloaded. As a result, the remote server is flooded with image requests, even if most of them will soon be thrown away by the client.

I see what you mean now. That’s definitely wasteful, and I believe this PR is working on overhauling that to make it a lot more efficient:

Which hopefully should be merged this month which would be a big win.

It sounds like the following is needed:

  1. Add a “refreshPeriod” option to ImageryProvider.
  2. ImageryProvider implementations would need to
  3. When “refreshPeriod” is supplied, keep a list of requests associated with the current view.
  4. Upon expiration of the “refreshPeriod” issue the saved list of requests.
  5. Update the scene with the new images as they arrive.
  6. Web Map Service must be configured to set the cache-control: max-age=“refreshPeriod” or similar.