From a06bc351e4ce68128def2148dc8adb6b44a3c406 Mon Sep 17 00:00:00 2001 From: crschmidt Date: Tue, 16 May 2006 23:54:34 +0000 Subject: [PATCH] Create redraw() function. This function does all of the drawing in the control: the draw function merely calls out to it. In addition, draw now does initialization of an event listener, listening for layers being added. This allows you to add the layer control before you've added all your layers, which was not possible before. It also allows, if desired, for us to add the LayerSwitcher control to the default controls, since it now will draw the layer switchers as they are added. git-svn-id: http://svn.openlayers.org/trunk/openlayers@67 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Control/LayerSwitcher.js | 32 ++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/OpenLayers/Control/LayerSwitcher.js b/lib/OpenLayers/Control/LayerSwitcher.js index 3fb05dae09..155978e76c 100644 --- a/lib/OpenLayers/Control/LayerSwitcher.js +++ b/lib/OpenLayers/Control/LayerSwitcher.js @@ -8,16 +8,32 @@ OpenLayers.Control.LayerSwitcher.prototype = draw: function() { // initialize our internal div OpenLayers.Control.prototype.draw.apply(this); + this.map.events.register("addlayer", this, this.redraw); + return this.redraw(); + }, + redraw: function() { var pixel = new OpenLayers.Pixel(this.map.div.clientWidth-200,4); + this.div.innerHTML = ""; for(i=0; i