button_url = "";
label = "";

L.Control.Legend =  L.Control.extend({

    options: {
      position: 'topleft'
    },

    onAdd: function (map) {
      container = L.DomUtil.create('div', 'leaflet-bar');
      legendButton = L.DomUtil.create('a',"leaflet-interactive polyline-measure-unicode-icon");
      container.appendChild(legendButton);
      legendButton.innerHTML = label;
      legendButton.title = "View legend"

      legendButton.onclick = function(){
        window.open(button_url, "_blank");
      }

      return container;
    }
  });

L.control.legend = function (options) {
    button_url = options.url;
    label = options.label;
	return new L.Control.Legend(options);
};