diff --git a/src/components/Map/markerManager.js b/src/components/Map/markerManager.js index 92f7100..f632aec 100644 --- a/src/components/Map/markerManager.js +++ b/src/components/Map/markerManager.js @@ -1,13 +1,13 @@ import maplibregl from "maplibre-gl"; /** - * Retire tous les marqueurs existants + * Supprime tous les marqueurs */ export function clearAllMarkers(markersRef, expandedElRef) { if (markersRef.current) { - for (const item of markersRef.current) { + for (const m of markersRef.current) { try { - item.marker.remove(); + m.marker.remove(); } catch { // ignore } @@ -20,14 +20,15 @@ export function clearAllMarkers(markersRef, expandedElRef) { } /** - * Crée un marqueur "pin" avec bulle + pointe. - * Position verrouillée sur [lon, lat] via MapLibre (anchor: 'bottom'). + * Crée un marqueur pour un post : + * - état compact : petite bulle + pointe + * - état étendu : gros post (carte) comme sur ton dessin */ export function createMarkerForPost(post, mapRef, markersRef, expandedElRef) { const map = mapRef.current; if (!map) return; - // --- Coordonnées --- + // --- coordonnées --- const lat = typeof post.lat === "number" ? post.lat @@ -52,63 +53,121 @@ export function createMarkerForPost(post, mapRef, markersRef, expandedElRef) { } const title = (post.title || post.Title || "").trim() || "Untitled"; - const snippet = + const body = (post.snippet || post.Snippet || "").trim() || (post.body || post.Body || "").trim() || title; - // --- DOM du pin --- + const author = (post.author || post.Author || "").trim() || "unknown"; + const created = + (post.created_at || post.CreatedAt || "").toString().slice(0, 19); + const category = (post.category || post.Category || "").toUpperCase() || ""; + const subCat = (post.sub_category || post.SubCategory || "").toString(); + const root = document.createElement("div"); - root.className = "post-pin"; + root.className = "post-pin post-pin--compact"; - const bubble = document.createElement("div"); - bubble.className = "post-pin-bubble"; + function renderCompact() { + root.className = "post-pin post-pin--compact"; + root.innerHTML = ` +