Show the legend only when the map is visible.