This commit is contained in:
bobbert committed 2025-03-16 21:50:38 +00:00
1 parent 25e877cc3a
commit 2236dceac9
4 files changed
+441 -125

No files matched your search

+44
View File
@@ -94,6 +94,30 @@
height: auto;
display: block;
object-fit: none; /* Don't constrain the SVG */
position: relative;
}
/* Force SVG elements to show properly with z-index */
.svg-container svg * {
transform-box: fill-box;
}
/* Ensure the clue points overlay is always on top */
.svg-container svg .clue-points-overlay {
position: relative !important;
z-index: 9999 !important;
pointer-events: all !important;
}
/* Make clue points very visible with stronger styling */
.svg-container .clue-point {
fill-opacity: 1 !important;
stroke-opacity: 1 !important;
pointer-events: all !important;
cursor: pointer !important;
stroke-width: 3px !important;
r: 14px !important;
filter: drop-shadow(0px 0px 5px rgba(0, 0, 0, 0.7)) !important;
}
/* Remove the default map background when we have the processed SVG */
@@ -277,6 +301,26 @@
color: #68543c;
}
/* Refresh map button styling */
.refresh-map-button {
position: fixed;
bottom: 80px;
right: 20px;
background-color: rgba(104, 84, 60, 0.9);
color: white;
border: none;
border-radius: 8px;
padding: 8px 16px;
font-size: 14px;
cursor: pointer;
z-index: 1000;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}
.refresh-map-button:hover {
background-color: rgba(104, 84, 60, 1);
}
/* Make sure the map is responsive */
@media (max-width: 480px) {
.team-name {
+75 -13
View File
@@ -15,6 +15,7 @@ import {
updateCluePointStatus,
attachClueClickHandlers,
} from "@/utils/map-populate";
import { addDebugOverlay, fixCluePointsRendering } from "@/utils/map-debug";
export default function MapPage() {
const { data: session, status } = useSession();
@@ -565,28 +566,73 @@ export default function MapPage() {
}
}, [status, fetchClues, loadAndEnhanceMap, router]);
// Modified useEffect to better handle SVG loading and enhancement
// Modified useEffect to ensure SVG elements are visible
useEffect(() => {
// Only try to enhance the map if both the SVG and clues are loaded
if (!mapSvg || !clues.length) return;
console.log("Both SVG and clues are loaded, preparing to enhance map");
// Ensure the SVG is fully loaded in the DOM before enhancing
requestAnimationFrame(() => {
// Longer timeout to ensure the SVG is fully rendered in the DOM
setTimeout(() => {
if (
mapContainerRef.current &&
mapContainerRef.current.querySelector("svg")
) {
console.log("SVG found in DOM, enhancing map now");
enhanceSvgMap();
let enhancementAttempts = 0;
const maxAttempts = 3;
function attemptMapEnhancement() {
enhancementAttempts++;
console.log(
`Map enhancement attempt ${enhancementAttempts}/${maxAttempts}`
);
if (
mapContainerRef.current &&
mapContainerRef.current.querySelector("svg")
) {
const svgElement = mapContainerRef.current.querySelector("svg");
console.log("SVG found in DOM, enhancing map now");
// Try to enhance the map
enhanceSvgMap();
// Additional check after brief delay to ensure visibility
setTimeout(() => {
const cluePoints = svgElement.querySelectorAll(".clue-point");
console.log(
`Found ${cluePoints.length} clue points after enhancement`
);
if (cluePoints.length === 0 && enhancementAttempts < maxAttempts) {
console.log(
`No clue points found, retrying (attempt ${enhancementAttempts}/${maxAttempts})`
);
attemptMapEnhancement();
} else if (cluePoints.length === 0) {
console.error(
`Failed to create clue points after ${maxAttempts} attempts`
);
// Fix rendering issues as a last resort
fixCluePointsRendering(svgElement);
} else {
console.log(
"Map enhancement successful, fixing any rendering issues"
);
fixCluePointsRendering(svgElement);
}
}, 300);
} else {
console.error("SVG not found in DOM after rendering timeout");
if (enhancementAttempts < maxAttempts) {
// Try again after a delay
setTimeout(attemptMapEnhancement, 500);
} else {
console.error("SVG not found in DOM after rendering timeout");
setMapError(true);
}
}, 500); // Increased timeout for better reliability on slower devices
}
}
// Ensure the SVG is fully loaded in the DOM before enhancing
requestAnimationFrame(() => {
// Initial delay before first attempt
setTimeout(attemptMapEnhancement, 300);
});
}, [mapSvg, clues, enhanceSvgMap]);
@@ -669,6 +715,22 @@ export default function MapPage() {
</div>
</div>
{/* Add a refresh button for users if they have issues with the map */}
{mapSvg && (
<button
className={styles["refresh-map-button"]}
onClick={() => {
const svgElement = mapContainerRef.current?.querySelector("svg");
if (svgElement) {
enhanceSvgMap();
setTimeout(() => fixCluePointsRendering(svgElement), 300);
}
}}
>
Refresh Map
</button>
)}
{/* Navigation bar */}
<nav className={styles["nav-bar"]}>
<Link