OpenLayers 2: WMS layer attribution legend doesn't change between WMS layers, it just piles up

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

OpenLayers 2: WMS layer attribution legend doesn't change between WMS layers, it just piles up

Gery
This post has NOT been accepted by the mailing list yet.
I'm using [this][1] to put legends in WMS layers. It works nicely when similar layers have the same legend (eg. layer A1 with legend AAA and layer A2 with legend AAA). The problem is when WMS layers have different legends.

For instance, when two different layers are checked (ie. layer A1 with legend AAA and layer B1 with legend BBB), both legends pile up, so legend AAA is shifted upwards with regard legend BBB.

It seems to me that the issue is around line 103 of the OpenLayers.Control.Attribution code: https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Control/Attribution.js, is that right? I'm not sure how to modify the original code to avoid that behavior, and much better, modify it to only display the legend of last checked/clicked WMS layer.

Thanks for any pointers,

  [1]: http://gis.stackexchange.com/questions/83300/how-to-add-a-legend-and-toggle-the-legend-with-a-layer-in-openlayers/83329#83329