[OpenLayers-Users] Question about LayerSwitcher

Frédéric Therrien fredth at hotmail.com
Wed Jul 23 13:08:41 EDT 2008


Hey, I have a pretty simple question. My customer want me to customize the LayerSwitcher. Do you think it's possible ?
 
In fact, here is want I want to do:
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.
 
Do you have any idea of how I can make it work ?
 
Here is the code I added:
if(!baseLayer)
{
var inputElemSelectedLayer = document.createElement("input");
inputElemSelectedLayer.id = "inputSelectedLayer_" + layer.name;
inputElemSelectedLayer.name = "selectedLayer";
inputElemSelectedLayer.type = "radio"; 

OpenLayers.Event.observe(inputElemSelectedLayer, "click", OpenLayers.Function.bindAsEventListener(this.onSelectedLayerClick, inputElemSelectedLayer));

groupDiv.appendChild(inputElemSelectedLayer);
}
in the redraw function.
...
onSelectedLayerClick: function(e) {
if (!this.inputElem.disabled) {
this.inputElem.checked = true; 
}
OpenLayers.Event.stop(e);
}
 
 
Thx a lot
 
Fred
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080723/a2dc80fd/attachment.html


More information about the Users mailing list