Sundsvallskommun / OpenEMap-WebUserInterface

Open eMap user interface for the main map client
GNU Affero General Public License v3.0
4 stars 5 forks source link

Legend - does not work when using group layers (4h?) #124

Closed anderserla closed 9 years ago

anderserla commented 9 years ago

Do the following

  1. Open a map that has a group layer defined and a layer with legend
  2. Click on a layer supporting a legend-> legend image shows
  3. Turn a layer on/off
  4. Click on a layer supporting a legend-> ERROR legend image DONT show
anderserla commented 9 years ago

The problem only seems to be when a layer is turned on (checked).

ghost commented 9 years ago

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.

ghost commented 9 years ago

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.

ghost commented 9 years ago

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.

ghost commented 9 years ago

Reworked to show legend as tooltip when clicking the small inline legend.