always delete everything and rebuild everything on redraw(). Just simpler this way
git-svn-id: http://svn.openlayers.org/trunk/openlayers@81 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -45,38 +45,40 @@ OpenLayers.Control.LayerSwitcher.prototype =
|
|||||||
* @type DOMElement
|
* @type DOMElement
|
||||||
*/
|
*/
|
||||||
redraw: function() {
|
redraw: function() {
|
||||||
var pixel = new OpenLayers.Pixel(this.map.div.clientWidth - 200, 4);
|
|
||||||
|
//clear out previous incarnation of LayerSwitcher tabs
|
||||||
this.div.innerHTML = "";
|
this.div.innerHTML = "";
|
||||||
|
|
||||||
|
var pixel = new OpenLayers.Pixel(this.map.div.clientWidth - 200, 4);
|
||||||
for(i=0; i < this.map.layers.length; i++) {
|
for(i=0; i < this.map.layers.length; i++) {
|
||||||
var div = $('LayerControl_layer' + i);
|
|
||||||
if (!div) {
|
|
||||||
div = OpenLayers.Util.createDiv("LayerControl_layer" + i,
|
|
||||||
pixel,
|
|
||||||
new OpenLayers.Size(200, 20));
|
|
||||||
|
|
||||||
div.innerHTML = this.map.layers[i].name;
|
div = OpenLayers.Util.createDiv("LayerControl_layer" + i,
|
||||||
var visible = this.map.layers[i].getVisibility();
|
pixel,
|
||||||
if (!visible) {
|
new OpenLayers.Size(200, 20));
|
||||||
div.style.backgroundColor =
|
|
||||||
OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
|
|
||||||
div.style.color =
|
|
||||||
OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
|
|
||||||
} else {
|
|
||||||
div.style.backgroundColor =
|
|
||||||
OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
|
|
||||||
div.style.color =
|
|
||||||
OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
|
|
||||||
}
|
|
||||||
div.style.padding = "5px";
|
|
||||||
|
|
||||||
//tag references onto the div for use in event handlers
|
div.innerHTML = this.map.layers[i].name;
|
||||||
div.layerid = i;
|
var visible = this.map.layers[i].getVisibility();
|
||||||
div.map = this.map;
|
if (!visible) {
|
||||||
|
div.style.backgroundColor =
|
||||||
div.ondblclick = this.doubleClick.bindAsEventListener(div);
|
OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
|
||||||
div.onmousedown = this.singleClick.bindAsEventListener(div);
|
div.style.color =
|
||||||
this.div.appendChild(div);
|
OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
|
||||||
|
} else {
|
||||||
|
div.style.backgroundColor =
|
||||||
|
OpenLayers.Control.LayerSwitcher.ACTIVE_COLOR;
|
||||||
|
div.style.color =
|
||||||
|
OpenLayers.Control.LayerSwitcher.NONACTIVE_COLOR;
|
||||||
}
|
}
|
||||||
|
div.style.padding = "5px";
|
||||||
|
|
||||||
|
//tag references onto the div for use in event handlers
|
||||||
|
div.layerid = i;
|
||||||
|
div.map = this.map;
|
||||||
|
|
||||||
|
div.ondblclick = this.doubleClick.bindAsEventListener(div);
|
||||||
|
div.onmousedown = this.singleClick.bindAsEventListener(div);
|
||||||
|
this.div.appendChild(div);
|
||||||
|
|
||||||
pixel = pixel.add(0, 35);
|
pixel = pixel.add(0, 35);
|
||||||
}
|
}
|
||||||
return this.div;
|
return this.div;
|
||||||
|
|||||||
Reference in New Issue
Block a user