Skip to content

Commit 85ed42f

Browse files
committed
fix(interactivity): interactivity crashes on click on building
1 parent 3e587be commit 85ed42f

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

src/js/map-interactivity/feature-property-filter.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,13 @@ const featurePropertyFilter = (feature) => {
182182
}
183183
if(date_d_apparition) {
184184
let match = date_d_apparition.match("([0-9]+)/");
185-
let year = match[1] ? match[1] : "";
186-
result.before += `Année de construction : ${year}<br/>`;
185+
if (!match) {
186+
match = date_d_apparition.match("([0-9]+)-");
187+
}
188+
if (match) {
189+
let year = match[1] ? match[1] : "";
190+
result.before += `Année de construction : ${year}<br/>`;
191+
}
187192
}
188193
}
189194

src/js/map-interactivity/gfi-rules.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ const gfiRules = {
1616
* @returns {Object} {title: ..., html: ...} pour l'affichage
1717
*/
1818
parseGFI: (rule, gfi, zoom) => {
19+
if (gfi.features.length == 0) {
20+
return;
21+
}
1922
const result = {
2023
geometry: gfi.features[0].geometry,
2124
};

src/js/map-interactivity/map-interactivity.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ class MapInteractivity {
245245
DOM.$mapCenter.classList.remove("loading");
246246
DOM.$mapCenter.classList.add("d-none");
247247
try {
248-
this.#highlightGFI(resp.geometry);
248+
if (resp && resp.geometry) {
249+
this.#highlightGFI(resp.geometry);
250+
}
249251
} catch (e) {
250252
console.warn(e);
251253
}

0 commit comments

Comments
 (0)