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

francescoboccacci at libero.it francescoboccacci at libero.it
Tue Feb 14 06:41:25 EST 2012


Yes, you are right... 
This is the procedure that i used:

1- I modified the file ../lib/OpenLayers/Control/LayerSwitcher.js in this way:

       - I comment all the line  that contain dataLbl :

                            /** 
                             * Property: dataLbl
                             * {DOMElement} 
                             */
                             //dataLbl: null,
                              ........

                             //this.dataLbl.style.display = (containsOverlays) 
? "" : "none";    
                             ......

                             //this.dataLbl = document.createElement("div");
                             //this.dataLbl.innerHTML = OpenLayers.i18n
("Layers");
                             //OpenLayers.Element.addClass(this.dataLbl, 
"dataLbl");

                             .....

                             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);
                              }

    after all i recompiled OpenLayers.js file  in this way :

 ../OpenLayers-2.11/build# ./build.py full.cfg OpenLayers.js

That's all ... There is anoter way to do that directly into the html file 
after:

 map.addControl( new OpenLayers.Control.LayerSwitcher({ ....

just add this line:

document.getElementsByClassName("dataLbl")[0].innerHTML =""

That's all.

Francesco Boccacci












>----Messaggio originale----
>Da: ahocevar at opengeo.org
>Data: 14/02/2012 12.13
>A: "francescoboccacci at libero.it"<francescoboccacci at libero.it>
>Cc: <openlayers-users at lists.osgeo.org>
>Ogg: Re: [OpenLayers-Users] Hide Overlay Laben in OpenLayers.Control.
LayerSwitcher
>
>It would be good practice to summarize what was done to solve an
>issue, because for people finding this in the archive it is annoying
>to only find "I solved it..." without any hints on HOW.
>
>Andreas.
>
>On Tue, Feb 14, 2012 at 11:08 AM, francescoboccacci at libero.it
><francescoboccacci at libero.it> wrote:
>> Hi all,
>> i solved it..
>>
>> Francesco
>>
>>>----Messaggio originale----
>>>Da: francescoboccacci at libero.it
>>>Data: 13/02/2012 21.37
>>>A: <openlayers-users at lists.osgeo.org>
>>>Ogg: [OpenLayers-Users] Hide Overlay Laben in  OpenLayers.Control.
>> LayerSwitcher
>>>
>>>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
>>>
>>>_______________________________________________
>>>Users mailing list
>>>Users at lists.osgeo.org
>>>http://lists.osgeo.org/mailman/listinfo/openlayers-users
>>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
>
>-- 
>Andreas Hocevar
>OpenGeo - http://opengeo.org/
>Expert service straight from the developers.
>




More information about the Users mailing list