I tried to add indexes to the unique id that is generated twice but it does not seem to be enough:
if (isNaN(window.mapIndex)) {
window.mapIndex = 0;
document.querySelectorAll('[id^="leaflet-map"]').forEach((element, index) => {
element.classList.add("leafleft-map");
element.id = element.id + "-" + index;
});
} else {
window.mapIndex = window.mapIndex + 1;
}
var map = L.map('leaflet-map-' + window.mapIndex, { dragging: !L.Browser.mobile, tap:!L.Browser.mobile });
`