Closed anderserla closed 9 years ago
The problem only seems to be when a layer is turned on (checked).
I have investigated the issue and the conclusion is that the (dynamically created) element that contains the legend is removed from DOM completely when clicking the visibility checkbox. Why this happens is unknown and requires diving deep into GeoExt and Ext JS which makes this issue non-trivial to fix :(
For reference this code toggles visibility on node click: https://github.com/Sundsvallskommun/OpenEMap-WebUserInterface/blob/develop/src/main/javascript/view/layer/Tree.js#L70
For reference this line defines the legend when node is created: https://github.com/Sundsvallskommun/OpenEMap-WebUserInterface/blob/develop/src/main/javascript/data/GroupedLayerTree.js#L196
NOTE: Node legend is only defined by Open eMap code - the actual creation is then done by Ext JS and GeoExt.
Problem lies in GeoExt2 logic that normally toggles visiblity of legend with layer visibility. We create a GeoExt2 WmsLegend manually to avoid this but logic is still triggered with the effect of removing the element. Possibly this can be hacked around in GeoExt2 WmsLegend. No success yet though.
No luck. I cannot find out why the element is removed from DOM. It must be fixable but need to rewrite all related code and dive deeper into GeoExt and Ext JS. The code that defines the legend is probably too much of a hack.
Reworked to show legend as tooltip when clicking the small inline legend.
Do the following