polylines tooltip content
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
// pages/index.js
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import dynamic from "next/dynamic";
|
||||
import { useRecoilState, useRecoilValue } from "recoil";
|
||||
import { readPoiMarkersStore } from "../store/selectors/readPoiMarkersStore"; // Aktualisiert mit atom
|
||||
import { readPoiMarkersStore } from "../store/selectors/readPoiMarkersStore";
|
||||
import { poiReadFromDbTriggerAtom } from "../store/atoms/poiReadFromDbTriggerAtom";
|
||||
|
||||
const MapComponentWithNoSSR = dynamic(
|
||||
() => import("../components/MapComponent"),
|
||||
{ ssr: false }
|
||||
);
|
||||
const MapComponentWithNoSSR = dynamic(() => import("../components/MapComponent"), { ssr: false });
|
||||
|
||||
export default function Home() {
|
||||
const poiReadTrigger = useRecoilValue(poiReadFromDbTriggerAtom);
|
||||
@@ -24,14 +20,12 @@ export default function Home() {
|
||||
}
|
||||
const data = await response.json();
|
||||
setLocations(data);
|
||||
//console.log("Geladene Daten in Home.js:", data);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// URL-Parameter abfragen
|
||||
function getURLParameter(name) {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
return params.get(name);
|
||||
@@ -39,10 +33,7 @@ export default function Home() {
|
||||
setMParam(getURLParameter("m"));
|
||||
setUParam(getURLParameter("u"));
|
||||
|
||||
// Daten beim Laden der Seite holen
|
||||
loadData();
|
||||
|
||||
//console.log("poiReadTrigger in Home.js:", poiReadTrigger);
|
||||
}, [poiReadTrigger]);
|
||||
|
||||
const handleAddLocation = async (name, type, lat, lng) => {
|
||||
@@ -55,37 +46,24 @@ export default function Home() {
|
||||
if (!response.ok) {
|
||||
throw new Error("Fehler beim Hinzufügen des Standorts");
|
||||
}
|
||||
console.log("Standort erfolgreich hinzugefügt");
|
||||
loadData(); // Aktualisiere die Daten nach dem Hinzufügen
|
||||
console.log("poiReadTrigger in Home.js:", poiReadTrigger);
|
||||
//console.log("Standort erfolgreich hinzugefügt");
|
||||
loadData();
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleLocationUpdate = (id, newLatitude, newLongitude) => {
|
||||
setLocations((prevLocations) =>
|
||||
prevLocations.map((location) =>
|
||||
location.idPoi === id
|
||||
? { ...location, position: `POINT(${newLongitude} ${newLatitude})` }
|
||||
: location
|
||||
)
|
||||
);
|
||||
setLocations((prevLocations) => prevLocations.map((location) => (location.idPoi === id ? { ...location, position: `POINT(${newLongitude} ${newLatitude})` } : location)));
|
||||
};
|
||||
//------------------------------------
|
||||
// Daten beim Laden der Seite holen
|
||||
|
||||
useEffect(() => {
|
||||
loadData();
|
||||
//console.log("poiReadTrigger in Home.js:", poiReadTrigger);
|
||||
}, [poiReadTrigger]);
|
||||
//------------------------------------
|
||||
|
||||
return (
|
||||
<div>
|
||||
<MapComponentWithNoSSR
|
||||
locations={locations}
|
||||
onAddLocation={handleAddLocation}
|
||||
onLocationUpdate={handleLocationUpdate}
|
||||
/>
|
||||
<MapComponentWithNoSSR locations={locations} onAddLocation={handleAddLocation} onLocationUpdate={handleLocationUpdate} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user