[OpenLayers-Users] Layerswitcher, how to hide overlay checkbox for a layer?

Jürgen Dankoweit Juergen.Dankoweit at T-Online.de
Wed Dec 18 04:14:00 PST 2013


Hello,

Am 18.12.2013 05:41, schrieb Dmitry Kuzhanov:
> Hi again, 
> Sorry for the brake..
> Basically I wanted to replace traditionally styled checkboxes with nice
> toggles. As far as I understand checkbox style class is being generated
> inside openlayers.js file. I've found the code and replaced style name
> with my own class. As a result currently it generates nice on/off button. 
> I'm sure you can also reset the class name to smth different or none
> value and get rid of checkboxes.

What about using "document.getElementsByName(<layername>)".
When looking at the DOM element structure of the layerswitch you will
see that the name attribute of the checkbox is identical to the name of
the layer.

A short code snippet:

s = NAME_OF_THE_LAYER_AS_SHOWN_IN_LAYERSWITCHER

var d = document.getElementsByName(s);
console.log(d);
for (i = 0; i < d.length; i++) {
 if (d[i].type == "checkbox") {
  console.log(d[i]);
  d[i].hidden=true;
 }
}

Put this code in the maximizeControl callback of the layersitcher

Best regards

Juergen

> 
> 
> среда, 18 декабря 2013 г. пользователь Dmitry Kuzhanov писал:
> 
>     Hi, I was recently working on the similar issue, but my idea was to rep
> 
>     четверг, 12 декабря 2013 г. пользователь Basques, Bob (CI-StPaul) писал:
> 
>         All,____
> 
>         __ __
> 
>         Is there an easy way to still display the layer title in the
>         switcher, but also hide the checkbox.  I want a layer title in
>         the switcher that is always on (This is cannot be a baselayer!!,
>         I need to put things under/over it as far as other layers are
>         concerned.)____
> 
>         __ __
> 
>         Thanks____
> 
>         __ __
> 
>         __ __
> 
>         __ __
> 
>         Bobb____
> 
>         __ __
> 
>         __ __
> 
> 
> 
>     //
> 
> 
> 
> -- 
> С Уважением, Дмитрий Кужанов./
> 
> Московский государственный университет им. М.В. Ломоносова
> Географический факультет
> Кафедра картографии и геоинформатики
> 8 906 755 06 99
> 
> ///
> 
> 
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 


-- 
Meine stets unfertige Homepage: www.dankoweit.de


More information about the Users mailing list