bug fix
All checks were successful
Build and Push Docker Image / build-and-push (push) Successful in 58s

This commit is contained in:
Tudor
2026-01-08 23:29:48 +00:00
parent b7943e1042
commit 3f8e1911aa

View File

@@ -610,23 +610,47 @@ function formatMetricValue(value, metric) {
* Initialize Leaflet maps for all school cards in a container
*/
function initializeSchoolMaps(container) {
// Check if Leaflet is loaded
if (typeof L === "undefined") {
console.warn("Leaflet not loaded yet, skipping map initialization");
return;
}
const mapElements = container.querySelectorAll(".school-map");
if (mapElements.length === 0) return;
// Clean up existing maps first
container.querySelectorAll(".school-map").forEach((mapEl) => {
mapElements.forEach((mapEl) => {
const existingMap = schoolMaps.get(mapEl);
if (existingMap) {
try {
existingMap.remove();
} catch (e) {
// Ignore cleanup errors
}
schoolMaps.delete(mapEl);
}
});
// Initialize new maps
container.querySelectorAll(".school-map").forEach((mapEl) => {
// Initialize new maps with a small delay to ensure DOM is ready
setTimeout(() => {
mapElements.forEach((mapEl) => {
try {
// Skip if already initialized
if (schoolMaps.has(mapEl)) return;
const lat = parseFloat(mapEl.dataset.lat);
const lng = parseFloat(mapEl.dataset.lng);
const schoolName = mapEl.dataset.name;
if (isNaN(lat) || isNaN(lng)) return;
// Ensure element has dimensions
if (mapEl.offsetWidth === 0 || mapEl.offsetHeight === 0) {
console.warn("Map container has no dimensions, skipping");
return;
}
// Create map
const map = L.map(mapEl, {
center: [lat, lng],
@@ -654,7 +678,11 @@ function initializeSchoolMaps(container) {
e.stopPropagation();
openMapModal(lat, lng, schoolName);
});
} catch (err) {
console.error("Error initializing map:", err);
}
});
}, 100);
}
/**