Legend dynamically collapses keys if layer is on or off