L.OSM.key = function (options) {
- var control = L.OSM.sidebarPane(options, "key", null, "javascripts.key.title");
+ const control = L.OSM.sidebarPane(options, "key", null, "javascripts.key.title");
control.onAddPane = function (map, button, $ui) {
- var $section = $("<div>")
- .attr("class", "section")
+ const $section = $("<div>")
+ .attr("class", "p-3")
.appendTo($ui);
$ui
}
function updateButton() {
- var disabled = ["mapnik", "cyclemap"].indexOf(map.getMapBaseLayerId()) === -1;
+ const disabled = OSM.LAYERS_WITH_MAP_KEY.indexOf(map.getMapBaseLayerId()) === -1;
button
.toggleClass("disabled", disabled)
.attr("data-bs-original-title",
}
function update() {
- var layer = map.getMapBaseLayerId(),
- zoom = map.getZoom();
+ const layerId = map.getMapBaseLayerId(),
+ zoom = map.getZoom();
$(".mapkey-table-entry").each(function () {
- var data = $(this).data();
- if (layer === data.layer && zoom >= data.zoomMin && zoom <= data.zoomMax) {
- $(this).show();
- } else {
- $(this).hide();
- }
+ const data = $(this).data();
+ $(this).toggle(
+ layerId === data.layer &&
+ (!data.zoomMin || zoom >= data.zoomMin) &&
+ (!data.zoomMax || zoom <= data.zoomMax)
+ );
});
}
};