From 305da30b88a911174c5eaeb1209dac496cb01ea5 Mon Sep 17 00:00:00 2001 From: you Date: Tue, 24 Mar 2026 20:24:26 +0000 Subject: [PATCH] fix: run map.invalidateSize before marker decollision on every render On SPA navigation, the map container may not have its final dimensions when markers render, causing latLngToLayerPoint to return incorrect pixel coordinates for decollision. This resulted in overlapping markers that only resolved on a full page refresh. Fix: call map.invalidateSize() at the start of every renderMarkers() call, ensuring correct container dimensions before deconfliction runs. --- public/index.html | 50 +++++++++++++++++++++++------------------------ public/map.js | 4 ++++ 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/public/index.html b/public/index.html index 2d2b64a..95aa33d 100644 --- a/public/index.html +++ b/public/index.html @@ -22,9 +22,9 @@ - - - + + + @@ -81,27 +81,27 @@
- - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/public/map.js b/public/map.js index 3eb9d54..dff58be 100644 --- a/public/map.js +++ b/public/map.js @@ -619,6 +619,10 @@ } } + // Ensure map has correct pixel dimensions before deconfliction + // (SPA navigation may render markers before container is fully sized) + map.invalidateSize({ animate: false }); + // Deconflict ALL markers if (allMarkers.length > 0) { deconflictLabels(allMarkers, map);