[OpenLayers-Dev] Help needed to customize (a bit only) LayerSwitcher control

MvdWeide openlayers at turbas.nl
Wed Oct 8 05:20:09 EDT 2008


Currently the LayerSwitcher does not support styling. If you look at the code
for the control it says in the maximizeControl function:

//HACK HACK HACK - find a way to auto-size this layerswitcher
this.div.style.width = "20em";

In this line of code you can change the "20em" part to something you want. I
think it would be a good option to declare a new property in the
LayerSwitcher to contain and determine the width of the div. You can then
give it a default you'd like.

/**
  * APIProperty: divWidth
  * {int} 
  * Defaults to 200px
  */
  divWidth: 200,

Ofcourse you must change the first mentioned line of code to:
this.div.style.width = this.divWidth +'px';

In this kind of structure you can override the default at initialization bij
setting the divWidth in the option-object.

You also could go for an auto-size method. In that situation you should
adjust the 'redraw' function to use the
'OpenLayers.Util.getRenderedDimensions' function to get the renderedSize of
the innerDiv. If it is bigger than the last known renderedSize you can
update the divWidth property. The next time you call the function
'maximizeControl' is called it will use the new divWidth. It will take some
coding, but it could be worth it.

This solution is based on the presumption that u use your own local copy of
the OpenLayers framework and that you can change te code. If you do not have
that option you will fall back on the first mentioned line of code which
tell you that it is not possible and you will be stuck at the '20em'

I hope this helps



jecheve wrote:
> 
> Please, I would appreciate some help about how I can change width of the
> div in which LayerSwitcher control is contained.
> 
> I do not need more functionality for this control, but I can not believe
> there is no reasonable way of styling it.
> 
> Only changing width!
> 
> Please, I am in trouble. I need layer names not to wrap and wrap around
> 
> Thanks in advance,
> 
> Javier
> 
> 

-- 
View this message in context: http://n2.nabble.com/Help-needed-to-customize-%28a-bit-only%29-LayerSwitcher-control-tp1304674p1306118.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list