Hi
I looked a bit further into this. What the Refresh strategy does is to
trigger a function called 'refresh' on the layer. For the a Vector layer the
refresh function just trigger an 'refresh' event if the layer is visible.
Any event listeners for this layer that listens to 'refresh' events will be
triggered.
You must set the parameter 'interval' for the refresh strategy to make it
work:
var refreshStrategy = new OpenLayers.Strategy.Refresh({interval: 1000});
Note that this is the time in milliseconds, if it is 0, it will not trigger
refresh at all.
I made a code demo:
var map;
function init() {
map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: 'basic'});
var refreshStrategy = new
OpenLayers.Strategy.Refresh({interval: 1000});
var vectorLayer = new OpenLayers.Layer.Vector(
"Refres Vector Layer",
{
strategies:[refreshStrategy]
});
vectorLayer.events.on({'refresh': function(e) {
OpenLayers.Console.log("Refresh performed");
}});
map.addLayers([wms, vectorLayer]);
map.addControl( new OpenLayers.Control.LayerSwitcher({'div':
$('laySwitch')}) );
map.zoomToMaxExtent();
}
This prints out "Refresh performed" on the debug console (ie. firebug).
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Refresh-Strategy-how-to-use-tp5813160p5818149.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users