+ $("<p>")
+ .text(I18n.t("javascripts.map.layers.overlays"))
+ .attr("class", "text-body-secondary small mb-2")
+ .appendTo(overlaySection);
+
+ var overlays = $("<ul class='list-unstyled form-check'>")
+ .appendTo(overlaySection);
+
+ var addOverlay = function (layer, name, maxArea) {
+ var item = $("<li>")
+ .appendTo(overlays);
+
+ if (name === "notes" || name === "data") {
+ item
+ .attr("title", I18n.t("javascripts.site.map_" + name + "_zoom_in_tooltip"))
+ .tooltip("disable");
+ }
+
+ var label = $("<label>")
+ .attr("class", "form-check-label")
+ .appendTo(item);
+
+ var checked = map.hasLayer(layer);
+
+ var input = $("<input>")
+ .attr("type", "checkbox")
+ .attr("class", "form-check-input")
+ .prop("checked", checked)
+ .appendTo(label);
+
+ label.append(I18n.t("javascripts.map.layers." + name));
+
+ input.on("change", function () {
+ checked = input.is(":checked");
+ if (checked) {
+ map.addLayer(layer);
+ } else {
+ map.removeLayer(layer);
+ }
+ map.fire("overlaylayerchange", { layer: layer });
+ });
+
+ map.on("layeradd layerremove", function () {
+ input.prop("checked", map.hasLayer(layer));
+ });
+
+ map.on("zoomend", function () {
+ var disabled = map.getBounds().getSize() >= maxArea;
+ $(input).prop("disabled", disabled);
+
+ if (disabled && $(input).is(":checked")) {
+ $(input).prop("checked", false)
+ .trigger("change");
+ checked = true;
+ } else if (!disabled && !$(input).is(":checked") && checked) {
+ $(input).prop("checked", true)
+ .trigger("change");
+ }