<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>Hey, I have a pretty simple question. My customer want me to customize the LayerSwitcher. Do you think it's possible ?<BR>
&nbsp;<BR>
In fact, here is want I want to do:<BR>
In the layer switcher you have a list of baseLayer associated with a radiobutton and a list of the other layers associated with a checkbox. My client want me to add a radio button beside the checkbox of the layers to allow him to specify witch layer to use for a given action. I open OpenLayer.js and modify the js to add a radiobutton. For the visual part it's ok, I see them and it's working. On the first display, if I click on a radio, it works, but after, If I want to change (by clicking to another one) nothing is happening. I've debug with firebug and if I go step by step, I see that my radio is changing, but for some reason, it's going back to the first one right after.<BR>
&nbsp;<BR>
Do you have any idea of how I can make it work ?<BR>
&nbsp;<BR>
Here is the code I added:<BR><FONT color=#7f0055 size=2>
<P align=left>if</FONT><FONT size=2><FONT face="" color=#000000>(!baseLayer)</FONT></P>
<P align=left></FONT><FONT color=#7f0055 size=2>{</P>
<P align=left>var </FONT><FONT face="" color=#000000 size=2>inputElemSelectedLayer = document.createElement(</FONT><FONT color=#8e00ff size=2>"input"</FONT><FONT size=2><FONT color=#000000>);</FONT></P>
<P align=left>inputElemSelectedLayer.id = </FONT><FONT face="" color=#8e00ff size=2>"inputSelectedLayer_" </FONT><FONT face="" size=2>+ layer.name;</P>
<P align=left>inputElemSelectedLayer.name = </FONT><FONT face="" color=#8e00ff size=2>"selectedLayer"</FONT><FONT face="" size=2>;</P>
<P align=left>inputElemSelectedLayer.type = </FONT><FONT face="" color=#8e00ff size=2>"radio"</FONT><FONT face="" size=2>; </P>
<P align=left></P>
<P align=left>OpenLayers.Event.observe(inputElemSelectedLayer, </FONT><FONT face="" color=#8e00ff size=2>"click"</FONT><FONT face="" size=2>, OpenLayers.Function.bindAsEventListener(</FONT><FONT face="" color=#7f0055 size=2>this</FONT><FONT face="" size=2>.onSelectedLayerClick, inputElemSelectedLayer));</P>
<P align=left></P>
<P align=left>groupDiv.appendChild(inputElemSelectedLayer);</P>
</FONT><FONT color=#7f0055 size=2>}<BR></FONT>
in the <FONT face="" size=2>redraw function.</FONT><BR>
...<BR><FONT size=2>
<P align=left>onSelectedLayerClick: </FONT><FONT face="" color=#7f0055 size=2>function</FONT><FONT face="" size=2>(e) </FONT><FONT face="" color=#7f0055 size=2>{</P>
<P align=left>if </FONT><FONT face="" color=#000000 size=2>(!</FONT><FONT face="" color=#7f0055 size=2>this</FONT><FONT face="" color=#000000 size=2>.inputElem.disabled) </FONT><FONT face="" color=#7f0055 size=2>{</P>
<P align=left>this</FONT><FONT face="" color=#000000 size=2>.inputElem.checked = </FONT><FONT face="" color=#7f0055 size=2>true</FONT><FONT face="" size=2><FONT color=#000000>; </FONT></P>
<P align=left></FONT><FONT color=#7f0055 size=2>}</P>
<P align=left></FONT><FONT size=2><FONT face="" color=#000000>OpenLayers.Event.stop(e);</FONT></P>
</FONT><FONT color=#7f0055 size=2>}<BR></FONT>
&nbsp;<BR>
<FONT face="" size=2>&nbsp;<BR></FONT>
Thx a lot<BR>
&nbsp;<BR>
Fred<BR></body>
</html>