Source: map/tools/LayerLegendButton.js

  1. import { UiElement } from '../../ui/UiElement.js';
  2. import { LayerLegendOverview } from '../utils/LayerLegendOverview.js';
  3. export { LayerLegendButton };
  4. /**
  5. * Simple button to open the layer legend overview
  6. *
  7. * @author rhess <robin.hess@awi.de>
  8. *
  9. * @memberof vef.map.tools
  10. */
  11. class LayerLegendButton extends UiElement {
  12. constructor(map, position, layerTree) {
  13. super();
  14. this.map = map;
  15. this.position = position || "top-left";
  16. this.overview_ = new LayerLegendOverview(null, layerTree);
  17. // initialize element
  18. const element = this.getElement();
  19. element.classList.add("vef-tool");
  20. element.innerHTML = "<i class='vef vef-legend-small'></i>"
  21. element.title = "Show Layer Legends";
  22. element.addEventListener("click", () => this.overview_.open());
  23. this.map.addTool(this, this.position);
  24. }
  25. }