ol-ext: control layer legends
ol/legend/Legend
can be associated with a layer and displayed when the layer is visible only.
This example displays 2 legends associated with layers.