[OpenLayers-Users] Hide Overlay Laben in OpenLayers.Control.LayerSwitcher

francescoboccacci at libero.it francescoboccacci at libero.it
Mon Feb 13 15:37:13 EST 2012


Hi all,
i would like to hide the Overlay Label in my OpenLayers.Control.LayerSwitcher. 
Is it possible?
i tried in this way:

map.addControl( new OpenLayers.Control.LayerSwitcher({
                      
                        dataLbl : "",


but it doesn't work.

My html file i add :
<script type="text/javascript" src="OpenLayers-2.11/OpenLayers.js">
to read directly to the OpenLayer folder in localserver.
I tried also to comment these lines in:
../OpenLayers-2.11/lib/OpenLayers/Control/LayerSwitcher.js

 loadContents: function() {

        //configure main div

        OpenLayers.Event.observe(this.div, "mouseup",
            OpenLayers.Function.bindAsEventListener(this.mouseUp, this));
        OpenLayers.Event.observe(this.div, "click",
                      this.ignoreEvent);
        OpenLayers.Event.observe(this.div, "mousedown",
            OpenLayers.Function.bindAsEventListener(this.mouseDown, this));
        OpenLayers.Event.observe(this.div, "dblclick", this.ignoreEvent);

        // layers list div        
        //this.layersDiv = document.createElement("div");
        //this.layersDiv.id = this.id + "_layersDiv";
        //OpenLayers.Element.addClass(this.layersDiv, "layersDiv");

        this.baseLbl = document.createElement("div");
        this.baseLbl.innerHTML = OpenLayers.i18n("Base Layer");
        OpenLayers.Element.addClass(this.baseLbl, "baseLbl");

        this.baseLayersDiv = document.createElement("div");
        OpenLayers.Element.addClass(this.baseLayersDiv, "baseLayersDiv");

        //this.dataLbl = document.createElement("div");
        //this.dataLbl.innerHTML = OpenLayers.i18n("Overlay");
        //this.dataLbl.innerHTML = "<u>"+this.getOverlaysTitle()+"</u>"; 
        //OpenLayers.Element.addClass(this.dataLbl, "dataLbl");

        //this.dataLayersDiv = document.createElement("div");
        //OpenLayers.Element.addClass(this.dataLayersDiv, "dataLayersDiv");

        if (this.ascending) {
            this.layersDiv.appendChild(this.baseLbl);
            this.layersDiv.appendChild(this.baseLayersDiv);
            this.layersDiv.appendChild(this.dataLbl);
            this.layersDiv.appendChild(this.dataLayersDiv);
        } else {
            this.layersDiv.appendChild(this.dataLbl);
            this.layersDiv.appendChild(this.dataLayersDiv);
            this.layersDiv.appendChild(this.baseLbl);
            this.layersDiv.appendChild(this.baseLayersDiv);

..
but it doesn't work. Any suggestion?

Thanks

Francesco



More information about the Users mailing list