Skip to content

Commit 119984f

Browse files
committed
fix map interraction on zoom and missing tab
1 parent 9c76848 commit 119984f

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

atlas/static/mapGenerator.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
// Affiche ou masque l'onglet "choix des couches" (tab control)
2+
function toggleLayerTab(show) {
3+
const controltab = document.querySelector("#control-tab");
4+
const controltabContent = document.querySelector("#control-tab-content");
5+
if (controltab && controltabContent) {
6+
controltab.style.display = show ? "" : "none";
7+
controltabContent.style.display = show ? "" : "none";
8+
}
9+
}
110
// global :
211
let current_sensitivity_codes = []; // list of distinct cd_sensibility in geojson
312

@@ -16,11 +25,12 @@ const control = L.control.layers(null, null, {
1625
});
1726

1827
function clearObservationsFeatureGroup() {
19-
control._layers.forEach((elem) => {
20-
if (elem.name.includes("defaultOverlay")) {
21-
map.removeLayer(elem.layer);
22-
control.removeLayer(elem.layer);
28+
// Supprime toutes les couches d'observations (FeatureGroup créés dans createLayersSelector)
29+
Object.values(observationsFeatureGroup).forEach((featureGroup) => {
30+
if (map.hasLayer(featureGroup)) {
31+
map.removeLayer(featureGroup);
2332
}
33+
control.removeLayer(featureGroup);
2434
});
2535
}
2636

@@ -193,14 +203,6 @@ function createTabControl() {
193203
content.parentNode.insertBefore(div, content);
194204
div.querySelector("#control-tab-content").appendChild(content);
195205

196-
if (
197-
!configuration.AFFICHAGE_MAILLE &&
198-
configuration.COUCHES_SIG.length === 0
199-
) {
200-
document.querySelector("#control-tab").style.display = "none";
201-
document.querySelector("#control-tab-content").style.display = "none";
202-
}
203-
204206
const sheetName = document.querySelector("body").getAttribute("page-name");
205207

206208
let isMaille = false;
@@ -665,18 +667,15 @@ function displayMarkerLayerFicheEspece(
665667

666668
if (configuration.COUCHES_SIG.length === 0) {
667669
// In point only map, hide control tab if no COUCHES_SIG configured
668-
const controltab = document.querySelector("#control-tab");
669-
const controltabContent = document.querySelector(
670-
"#control-tab-content",
671-
);
670+
toggleLayerTab(false);
672671
const legendtab = document.querySelector("#legend-tab");
673672
const legendtabContent = document.querySelector(
674673
"#legend-tab-content",
675674
);
676-
controltab.style.display = "none";
677-
document.querySelector("#control-tab-content").style.display =
678-
"none";
679-
675+
const controltab = document.querySelector("#control-tab");
676+
const controltabContent = document.querySelector(
677+
"#control-tab-content",
678+
);
680679
// switch to legend tab
681680
legendtab.classList.add("active");
682681
legendtabContent.classList.add("active");

atlas/static/mapPoint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ function eventOnZoom(observationsMaille, observationsPoint) {
198198
.forEach((elem) => elem.remove());
199199
legendColorObs.appendChild(generateObservationsLegend(true));
200200

201+
toggleLayerTab(true);
201202
legendblock.removeAttr("hidden");
202203
displayGeojsonMailles(observationsMaille, onEachFeatureMaille);
203204
activeMode = "Maille";

0 commit comments

Comments
 (0)