const formatDate = (date) => { const day = date.getDate(); const month = date.getMonth() + 1; const year = date.getFullYear(); return `${day}/${month}/${year}`; }; const formatTime = (date) => { return date.toTimeString().split(" ")[0]; }; export function initMarkers(markerList, L, map) { markerList.forEach((customMarker) => { const marker = L.marker([customMarker.x, customMarker.y]).addTo(map); const popUpContentTitle = "
" + customMarker.description + "
"; const popUpContentImage = ""; const popUpContentDate = "Inserito il: " +
markerData.ts.substring(0, 10) +
"
alle " +
markerData.ts.substring(11, 16) +
"
" + markerData.description + "
"; const popUpContentImage = ""; const popUpContentDate = `Inserito il: ${formatDate(
date
)}
alle: ${formatTime(date)}
" + "alle: " + markerData.ts.substring(11, 16) + "
"; const popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage + popUpContentDate; //+ popUpContentHour marker.bindPopup(popUpContent); if (returnMarker) { return marker; } } export function createMarkerTemp(markerData, L, map, returnMarker = false) { const marker = L.marker([ markerData.coordinate.y, markerData.coordinate.x, ]).addTo(map); const popUpContentdescription = "" + markerData.description + "
"; const popUpContent = popUpContentdescription; marker.bindPopup(popUpContent); if (returnMarker) { return marker; } } export function updateMarkers(markerList, L, map) { const layers = L.LayerGroup(); //layers contains all markers.. const contained = []; //makers in map boundingbox layers.eachLayer(function (l) { if ( layer instanceof L.Marker && map.getBounds().contains(layer.getLatLng()) ) contained.push(layer); }); console.log(contained); }