On Wed, Jan 7, 2009 at 10:02 PM, Alexandre Dube <ad...@mapgears.com> wrote: > Dear list, > > I'm writing my own Control and I need to register some events. Doing > so in the initialize function isn't good because some objects are not > created yet ( like the map object ). So I thought I could register them > in the activate() func and unregister them in the deactivate() func. > > So far it was ok to do so, but now I'm facing a problem. I need to > register events that, when triggered, deactivate the control, and other > events that, when triggered, reactivate the control. It's a control > that can contain multiple layers that come from the same source but have > been normalized to render faster, so the user sees no difference when > zooming. The control change the opacity of a layer when the mouse is > over it and because the features generated come from different sources, > I need to deactivate the control while I'm zooming ( deactivate on > loadstart, activate on loadend ). This looks like this : > > // inside the activate function() > for (var key in this.layers){ > this.layers[key].events.register( > "loadstart", this, this.deactivate); > this.layers[key].events.register( > "loadend", this, this.activate); > } > > So basically I should unregister them in the deactivate function(), > right ? The problem is : if I deactivate the control, it will > unregister the loadend event so it will not be reactivated in the end. > Is there an other place I should register my events to avoid that > behavior ? I see in some other control registration on events in a > draw() function. Could I do something similar ?
Defining events that activate and deactivate a control in the control itself seems weird to me. Have you thought about implementing an external component controlling your control? -- Eric _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users