Use custom marker.png for Leaflet map markers

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serreau Jovann
2026-03-20 18:46:39 +01:00
parent b208c7529e
commit 0a758c0ccc
2 changed files with 8 additions and 1 deletions

View File

@@ -40,7 +40,14 @@ function geocodeAndRender(address, mapEl) {
subdomains: 'abcd',
}).addTo(map)
L.marker([lat, lon]).addTo(map).bindPopup('<b>' + address + '</b>').openPopup()
const icon = L.icon({
iconUrl: '/marker.png',
iconSize: [40, 40],
iconAnchor: [20, 40],
popupAnchor: [0, -40],
})
L.marker([lat, lon], { icon }).addTo(map).bindPopup('<b>' + address + '</b>').openPopup()
})
.catch(() => {
mapEl.innerHTML = '<div style="display:flex;align-items:center;justify-content:center;height:100%;background:#f3f4f6;"><p style="font-weight:700;color:#9ca3af;">Carte indisponible</p></div>'