add: marker poco temporaneo durante l'inserimento

This commit is contained in:
user 2024-08-17 21:35:03 +02:00
parent 78d4b6b216
commit f611832592
3 changed files with 17 additions and 3 deletions

View file

@ -1,6 +1,7 @@
import { processForm } from "./formHandler.js";
import { basicElements } from "./getHtmlElements.js";
import {createMarker} from "./markerHandler.js";
let editMode = false
@ -30,7 +31,15 @@ export function initEvents(map){
noticeCoordsPicker.style.display = 'none';
remainingForm.style.display = 'block';
map.getContainer().style.cursor = 'auto';
// markerFormContainer.style.display = 'block';
const tmpMarker = {
coordinate: { x: formInputCoordX.value, y: formInputCoordY.value},
name: '',
description: '',
filename: '',
}
const marker = createMarker(tmpMarker, L, map)
// Va creata la logica di eliminazione del marker tmp
//localStorage.setItem("tmpMarkerId", marker._leaflet_id);
}
});
}

View file

@ -8,6 +8,8 @@ export async function processForm (e) {
const formData = new FormData(markerForm)
document.getElementById("markerFormContainer").style.display = 'none';
markerForm.reset();
// const tmpMarker = localStorage.getItem("tmpMarkerId");
// L.layerGroup().removeLayer(tmpMarker);
await fetch('/uploadMarker', {
method: 'POST',
body: formData,

View file

@ -9,13 +9,16 @@ export function initMarkers(markerList, L, map){
});
}
export function createMarker(markerData, L, map){
export function createMarker(markerData, L, map, returnMarker = false){
var marker = L.marker([markerData.coordinate.y, markerData.coordinate.x]).addTo(map);
let popUpContentTitle = "<h1>"+ markerData.name +"</h1>";
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
let popUpContentImage = "<img src='/imgs/"+ markerData.filename +"'</img>";
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage
marker.bindPopup(popUpContent);
if(returnMarker) {
return marker;
};
}
export function updateMarkers(markerList, L, map){