Hello Jay,

Thanks for your help. I ended up doing:

markers.events.on({ "featureselected": onMarkerSelect, "featureunselected": onMarkerUnselect, *"visibilitychanged": onMarkerToggle* });

function onMarkerToggle(event) { //ask for this layers refresh if visibility becomes true if(markers.visibility == true){ // alert("requesting marker refresh");
           updateActiveAlarms(); //this refreshes the layer
} }
It works perfectly. Thanks again,
Adrian

Jay Douillard wrote:
Adrian,

You need to register events to fire when want refreshing to occur.
You can use the visibility property of a layer to test if it is visible and 
only refresh those layers that are.
http://dev.openlayers.org/releases/OpenLayers-2.8/doc/apidocs/files/OpenLayers/Layer-js.html#OpenLayers.Layer.visibility

http://dev.openlayers.org/apidocs/files/OpenLayers/Events-js.html
----
Jay

----- Original Message -----
From: "Adrian Popa" <[email protected]>
To: [email protected]
Sent: Tuesday, July 14, 2009 11:27:17 PM GMT -08:00 US/Canada Pacific
Subject: [OpenLayers-Users] Overriding overlay select to force a reload of the 
toggled layer

Hi everybody,

I have several overlay vector layers that get their data in KML format from some server-side scripts. The data is highly dynamic, so it needs to be refreshed constantly (this is solved). The problem appears if only one overlay layer is selected (visible), I need to refresh all overlay layers so that if the user toggles another overlay, he will have the most recent data. I would like to reduce the overhead on the server and client side and only refresh the visible overlay layers, and to force a refresh of a layer whenever the user makes it visible. For this I would have to override the function that runs when a layer is selected in the layer switcher and call another refresh function before the layer is made visible. Can anyone point me in the right direction?

P.S. I would like to do this without editing the openlayers code; instead I would like to override/overload the function for my objects only.

Thanks,
Adrian

_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users


_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users

Reply via email to