def relevant_legend_info(layers, categories=(@options[:category] ? [@options[:category]] : @options[:categories]))
      legend_info = layers.inject([]) do |arr, layer|
        if categories.nil? ||
         (categories.include?(layer.options[:category]) ||
         (layer.options[:categories] && (categories & layer.options[:categories]).size > 0) )
          
          data = layer.legend_data
          arr << data if data.is_a?(Hash)
          arr = arr + data if data.is_a?(Array)
        end
        arr
      end
    end
def relevant_legend_info(layers, categories=(@options[:category] ? [@options[:category]] : @options[:categories]))
      legend_info = layers.inject([]) do |arr, layer|
        if categories.nil? ||
         (categories.include?(layer.options[:category]) ||
         (layer.options[:categories] && (categories & layer.options[:categories]).size > 0) )
          
          data = layer.legend_data
          arr << data if data.is_a?(Hash)
          arr = arr + data if data.is_a?(Array)
        end
        arr
      end
    end
Collects Legend Info from the provided Layers.

 Automatically filters by legend's categories.