[OpenLayers-Dev] refresh layers

Angus Carr angus.carr at gmail.com
Fri May 18 14:18:05 EDT 2007

Thanks, Tim. That's exactly what I needed.

For the sake of the list...

Add this to the init function:
 window.setInterval(refresh, 60000, layer);

Then add a refresh function:
 function refresh(layer) {
            layer.moveTo(layer.map.getExtent(), true);

Tada!... With a slight flash on redraw, it's refreshing every minute.
I tried it at 1000 for the sake of demostration, but it was annoying

On 5/18/07, Tim Schaub <noreply at geocartic.com> wrote:
> 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.
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

More information about the Dev mailing list