add: marker poco temporaneo durante l'inserimento
This commit is contained in:
parent
78d4b6b216
commit
f611832592
3 changed files with 17 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
|
|
||||||
import { processForm } from "./formHandler.js";
|
import { processForm } from "./formHandler.js";
|
||||||
import { basicElements } from "./getHtmlElements.js";
|
import { basicElements } from "./getHtmlElements.js";
|
||||||
|
import {createMarker} from "./markerHandler.js";
|
||||||
|
|
||||||
let editMode = false
|
let editMode = false
|
||||||
|
|
||||||
|
@ -30,7 +31,15 @@ export function initEvents(map){
|
||||||
noticeCoordsPicker.style.display = 'none';
|
noticeCoordsPicker.style.display = 'none';
|
||||||
remainingForm.style.display = 'block';
|
remainingForm.style.display = 'block';
|
||||||
map.getContainer().style.cursor = 'auto';
|
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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
|
@ -8,6 +8,8 @@ export async function processForm (e) {
|
||||||
const formData = new FormData(markerForm)
|
const formData = new FormData(markerForm)
|
||||||
document.getElementById("markerFormContainer").style.display = 'none';
|
document.getElementById("markerFormContainer").style.display = 'none';
|
||||||
markerForm.reset();
|
markerForm.reset();
|
||||||
|
// const tmpMarker = localStorage.getItem("tmpMarkerId");
|
||||||
|
// L.layerGroup().removeLayer(tmpMarker);
|
||||||
await fetch('/uploadMarker', {
|
await fetch('/uploadMarker', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: formData,
|
body: formData,
|
||||||
|
|
|
@ -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);
|
var marker = L.marker([markerData.coordinate.y, markerData.coordinate.x]).addTo(map);
|
||||||
let popUpContentTitle = "<h1>"+ markerData.name +"</h1>";
|
let popUpContentTitle = "<h1>"+ markerData.name +"</h1>";
|
||||||
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
|
let popUpContentdescription = "<p>"+ markerData.description +"</p>";
|
||||||
let popUpContentImage = "<img src='/imgs/"+ markerData.filename +"'</img>";
|
let popUpContentImage = "<img src='/imgs/"+ markerData.filename +"'</img>";
|
||||||
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage
|
let popUpContent = popUpContentTitle + popUpContentdescription + popUpContentImage
|
||||||
marker.bindPopup(popUpContent);
|
marker.bindPopup(popUpContent);
|
||||||
|
if(returnMarker) {
|
||||||
|
return marker;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function updateMarkers(markerList, L, map){
|
export function updateMarkers(markerList, L, map){
|
||||||
|
|
Loading…
Reference in a new issue