[OpenLayers-Dev] Hiding Layers from the Layer Switcher

Christopher Schmidt crschmidt at metacarta.com
Wed Jul 18 18:45:51 EDT 2007


On Wed, Jul 18, 2007 at 05:21:45PM -0400, Peterson Eric-EEP002 wrote:
> I then run it in Firebug, set a breakpoint in updateLayerVisibility(),
> and click my checkboxes in the LayerSwitcher. But the breakpoint is
> never tripped ... The changelayer event is never being triggered.
> 
> I looked into the code a bit, and I think I may have found a bug in the
> LayerSwitcher.js file (the latest trunk version has this issue as well
> as 2.4). In the onInputClick() method, the 'changebaselayer' event is
> being triggered when the base layer changes, but there's no
> 'changelayer' event when an overlay layer changes. Should there be the
> following line between 284 and 285?
> 
> this.layer.map.events.triggerEvent("changelayer");

No -- the changelayer event should be fired by setVisibility.

However, after you sent this email, I was reminded that I had
established that this was explicitly set not to happen in the
LayerSwitcher.js:

    layerEntry.layer.setVisibility(layerEntry.inputElem.checked, true);

I never established why this was. Erik might have a better idea:

Erik, can you remember why we don't fire the event in this case? It's a
problem for the existing ticket (10something) on attribution, with a
patch by penyaskito. I think we need to figure out how to fire an event
here. 

Looking at it, it seems possible that firing an event would lead to 
an infinite loop. If that is the problem, we should discuss a resolution
to that. If you can confirm that, and open a bug for 2.5, that would be
great.


-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list