[OpenLayers-Dev] refresh layers

Tim Schaub noreply at geocartic.com
Fri May 18 12:57:39 EDT 2007


Angus Carr wrote:
> I have a time-sensitive layer which I need to reload on a regular
> basis. Until we started using OpenLayers, we used to reload the whole
> page on a timer. That approach now would re-zoom back to the full
> extent. I'd like users to be able to monitor a district for lightning
> strikes by zooming it and leaving it zoomed while it auto-refreshes
> the layers every five minutes.

See this example [1] for a layer that refreshes on a specified interval. 
  Unfortunately, Chris shut down his webcam long ago and now you get to 
sit and look at the same picture of him reload every 10 seconds.

If you view the source, you'll see the technique.  There are many ways 
to do the same, but the one I chose here was to have the refresh 
function call layer.moveTo with the second argument true (this forces 
the layer to redraw).

Hope that helps,
Tim

[1] http://dev.openlayers.org/sandbox/vector-2.4/examples/webcam.html
Link to no-longer live webcam that will likely disappear sometime soon.




More information about the Dev mailing list