ruscomap/public/js/markerHandler.js

46 lines
2.3 KiB
JavaScript
Raw Normal View History

2024-06-30 22:56:19 +02:00
export function initMarkers(markerList, L, map){
markerList.forEach(customMarker => {
var marker = L.marker([customMarker.x, customMarker.y]).addTo(map);
let popUpContentTitle = "<h1>"+ customMarker.title +"</h1>";
let popUpContentdescription = "<p>"+ customMarker.description +"</p>";
let popUpContentImage = "<img src='/img/"+ customMarker.imgName+"'</img>";
2024-08-22 17:29:00 +02:00
let popUpContentDate = "<br><p>Inserito il: " + markerData.ts.substring(0, 10) + "<br>alle " + markerData.ts.substring(11, 16) + "</p>";
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage + popUpContentDate
2024-06-30 22:56:19 +02:00
marker.bindPopup(popUpContent).openPopup();
});
}
export function createMarker(markerData, L, map, returnMarker = false){
2024-07-17 12:00:34 +02:00
var marker = L.marker([markerData.coordinate.y, markerData.coordinate.x]).addTo(map);
let popUpContentTitle = "<h1>"+ markerData.name +"</h1>";
2024-07-16 18:31:53 +02:00
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
2024-07-17 12:00:34 +02:00
let popUpContentImage = "<img src='/imgs/"+ markerData.filename +"'</img>";
2024-08-22 18:26:33 +02:00
let popUpContentDate = "<br><p>Inserito il: " + markerData.ts.substring(0, 10) + "<br>alle: " + markerData.ts.substring(11, 16) + "</p>";
//let popUpContentHour = "<p>" + "alle: " + markerData.ts.substring(11, 16) + "</p>";
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage + popUpContentDate //+ popUpContentHour
marker.bindPopup(popUpContent);
if(returnMarker) {
return marker;
};
2024-07-16 18:31:53 +02:00
}
2024-08-23 11:06:43 +02:00
export function createMarkerTemp(markerData, L, map, returnMarker = false){
var marker = L.marker([markerData.coordinate.y, markerData.coordinate.x]).addTo(map);
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
let popUpContent = popUpContentdescription
marker.bindPopup(popUpContent);
if(returnMarker) {
return marker;
};
}
2024-06-30 22:56:19 +02:00
export function updateMarkers(markerList, L, map){
var layers = L.LayerGroup(), //layers contains all markers..
contained = []; //makers in map boundingbox
layers.eachLayer(function(l) {
if( l instanceof L.Marker && map.getBounds().contains(l.getLatLng()) )
contained.push(l);
});
console.log(contained)
}