refactor: Quellcode aufräumen ,PoiUtils.js entfernt
This commit is contained in:
@@ -1,53 +0,0 @@
|
|||||||
//components/PoiUtils.js
|
|
||||||
import L from "leaflet";
|
|
||||||
|
|
||||||
// Funktion, um POI Markers zu erstellen
|
|
||||||
export const createPoiMarkers = (poiData, iconPath) => {
|
|
||||||
return poiData.map((location) => {
|
|
||||||
return L.marker([location.latitude, location.longitude], {
|
|
||||||
icon: L.icon({
|
|
||||||
iconUrl: iconPath,
|
|
||||||
iconSize: [25, 41],
|
|
||||||
iconAnchor: [12, 41],
|
|
||||||
popupAnchor: [1, -34],
|
|
||||||
draggable: true,
|
|
||||||
}),
|
|
||||||
id: location.idPoi,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funktion zum Hinzufügen von Markern zur Karte und zum Umgang mit Events
|
|
||||||
export const addMarkersToMap = (markers, map, layerGroup) => {
|
|
||||||
markers.forEach((marker) => {
|
|
||||||
marker.addTo(layerGroup);
|
|
||||||
marker.on("mouseover", () => marker.openPopup());
|
|
||||||
marker.on("mouseout", () => marker.closePopup());
|
|
||||||
marker.on("dragend", (e) => {
|
|
||||||
console.log("Marker wurde verschoben in addMarkersToMap");
|
|
||||||
const newLat = e.target.getLatLng().lat;
|
|
||||||
const newLng = e.target.getLatLng().lng;
|
|
||||||
const markerId = e.target.options.id;
|
|
||||||
updateLocationInDatabase(markerId, newLat, newLng);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funktion zum Aktualisieren der Standorte in der Datenbank
|
|
||||||
export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => {
|
|
||||||
const response = await fetch("/api/talas_v5_DB/pois/updateLocation", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({
|
|
||||||
id,
|
|
||||||
latitude: newLatitude,
|
|
||||||
longitude: newLongitude,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
console.error("Fehler beim Aktualisieren der Position");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Weitere Funktionen können hier hinzugefügt werden
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
// components/pois/PoiUtils.js
|
|
||||||
import L from "leaflet";
|
|
||||||
|
|
||||||
// Funktion, um POI Markers zu erstellen
|
|
||||||
export const createPoiMarkers = (poiData, iconPath) => {
|
|
||||||
return poiData.map((location) => {
|
|
||||||
return L.marker([location.latitude, location.longitude], {
|
|
||||||
icon: L.icon({
|
|
||||||
iconUrl: iconPath,
|
|
||||||
iconSize: [25, 41],
|
|
||||||
iconAnchor: [12, 41],
|
|
||||||
popupAnchor: [1, -34],
|
|
||||||
draggable: true,
|
|
||||||
}),
|
|
||||||
id: location.idPoi,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funktion zum Hinzufügen von Markern zur Karte und zum Umgang mit Events
|
|
||||||
export const addMarkersToMap = (markers, map, layerGroup) => {
|
|
||||||
markers.forEach((marker) => {
|
|
||||||
marker.addTo(layerGroup);
|
|
||||||
marker.on("mouseover", () => marker.openPopup());
|
|
||||||
marker.on("mouseout", () => marker.closePopup());
|
|
||||||
marker.on("dragend", (e) => {
|
|
||||||
console.log("Marker wurde verschoben in addMarkersToMap");
|
|
||||||
const newLat = e.target.getLatLng().lat;
|
|
||||||
const newLng = e.target.getLatLng().lng;
|
|
||||||
const markerId = e.target.options.id;
|
|
||||||
updateLocationInDatabase(markerId, newLat, newLng);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Funktion zum Aktualisieren der Standorte in der Datenbank
|
|
||||||
export const updateLocationInDatabase = async (id, newLatitude, newLongitude) => {
|
|
||||||
const response = await fetch("/api/talas_v5_DB/pois/updateLocation", {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify({
|
|
||||||
id,
|
|
||||||
latitude: newLatitude,
|
|
||||||
longitude: newLongitude,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!response.ok) {
|
|
||||||
console.error("Fehler beim Aktualisieren der Position");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Weitere Funktionen können hier hinzugefügt werden
|
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
// /config/appVersion
|
// /config/appVersion
|
||||||
export const APP_VERSION = "1.1.119";
|
export const APP_VERSION = "1.1.120";
|
||||||
|
|||||||
Reference in New Issue
Block a user