1 L.OSM.key = function (options) {
2 var control = L.control(options);
4 control.onAdd = function (map) {
5 var $container = $("<div>")
6 .attr("class", "control-key");
9 .attr("class", "control-button")
11 .html("<span class=\"icon key\"></span>")
13 .appendTo($container);
16 .attr("class", "key-ui");
19 .attr("class", "sidebar_heading")
22 $("<button type='button' class='btn-close float-end mt-1'>")
23 .attr("aria-label", I18n.t("javascripts.close"))
24 .bind("click", toggle))
27 .text(I18n.t("javascripts.key.title")));
29 var $section = $("<div>")
30 .attr("class", "section")
33 options.sidebar.addPane($ui);
39 map.on("baselayerchange", updateButton);
44 map.on("zoomend baselayerchange", update);
45 $section.load("/key", update);
49 map.off("zoomend baselayerchange", update);
55 if (!button.hasClass("disabled")) {
56 options.sidebar.togglePane($ui, button);
58 $(".leaflet-control .control-button").tooltip("hide");
61 function updateButton() {
62 var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1;
64 .toggleClass("disabled", disabled)
65 .attr("data-original-title",
67 "javascripts.key.tooltip_disabled" :
68 "javascripts.key.tooltip"));
72 var layer = map.getMapBaseLayerId(),
75 $(".mapkey-table-entry").each(function () {
76 var data = $(this).data();
77 if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {