import locations from "../../../json/location.json" (function () { "use strict"; $(".leaflet").each(async function () { const map = L.map(this, { center: [$(this).data("lat"), $(this).data("long")], zoom: 9, }); if (map) { const apiKey = $(this).data("api-key"); L.tileLayer( `https://tile.thunderforest.com/atlas/{z}/{x}/{y}@2x.png?apikey=${apiKey}`, { attribution: "Map data © OpenStreetMap contributors, Tiles © Thunderforest", } ).addTo(map); const markers = L.markerClusterGroup({ maxClusterRadius: 30, iconCreateFunction: function (cluster) { const color = $("html").hasClass("dark") ? getColor("darkmode.100", 0.6) : getColor("primary", 0.8); const mapMarkerRegionSvg = window.btoa(` `); return L.divIcon({ html: `
${cluster.getChildCount()}
`, className: "", iconSize: L.point(42, 42), iconAnchor: L.point(20, 45), }); }, spiderfyOnMaxZoom: false, showCoverageOnHover: false, }); map.addLayer(markers); const color = $("html").hasClass("dark") ? getColor("darkmode.100") : getColor("primary"); const mapMarkerSvg = window.btoa(` `); locations.map(function (markerElem) { const marker = L.marker( { lat: parseFloat(markerElem.latitude), lng: parseFloat(markerElem.longitude), }, { title: markerElem.name, icon: L.icon({ iconUrl: `data:image/svg+xml;base64,${mapMarkerSvg}`, iconAnchor: L.point(10, 35), }), } ); markers.addLayer(marker); }); } }); })();