/* global L */ export function initEventMap() { const mapEl = document.getElementById('event-map') if (!mapEl) return const address = mapEl.dataset.address if (!address) return const link = document.createElement('link') link.rel = 'stylesheet' link.href = 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.css' document.head.appendChild(link) const script = document.createElement('script') script.src = 'https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.min.js' script.onload = () => geocodeAndRender(address, mapEl) document.head.appendChild(script) } function geocodeAndRender(address, mapEl) { const url = 'https://nominatim.openstreetmap.org/search?format=json&limit=1&q=' + encodeURIComponent(address) globalThis.fetch(url) .then(r => r.json()) .then(data => { if (data.length === 0) { mapEl.innerHTML = '
Adresse introuvable sur la carte
Carte indisponible