Add OSM Objects to Mission
This commit is contained in:
@@ -152,6 +152,13 @@ export const ContextMenu = () => {
|
|||||||
}, [] as any);
|
}, [] as any);
|
||||||
|
|
||||||
setOpen(true);
|
setOpen(true);
|
||||||
|
|
||||||
|
const nodeWay: [number, number][] = [];
|
||||||
|
|
||||||
|
closestToContext.nodes.map((node: { lat: number; lon: number }) =>
|
||||||
|
nodeWay.push([node.lat, node.lon]),
|
||||||
|
);
|
||||||
|
|
||||||
setMissionFormValues({
|
setMissionFormValues({
|
||||||
addressLat: contextMenu.lat,
|
addressLat: contextMenu.lat,
|
||||||
addressLng: contextMenu.lng,
|
addressLng: contextMenu.lng,
|
||||||
@@ -159,7 +166,11 @@ export const ContextMenu = () => {
|
|||||||
addressStreet: `${addressObj.road || "keine Straße"}, ${addressObj.house_number || "keine HN"}`,
|
addressStreet: `${addressObj.road || "keine Straße"}, ${addressObj.house_number || "keine HN"}`,
|
||||||
addressZip: addressObj.postcode || "",
|
addressZip: addressObj.postcode || "",
|
||||||
state: "draft",
|
state: "draft",
|
||||||
addressOSMways: [(exactAddress || closestToContext) as any],
|
addressOSMways: [closestToContext],
|
||||||
|
});
|
||||||
|
|
||||||
|
map.setView([contextMenu.lat, contextMenu.lng], 18, {
|
||||||
|
animate: true,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -6,15 +6,12 @@ import L from "leaflet";
|
|||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { getMissionsAPI } from "querys/missions";
|
import { getMissionsAPI } from "querys/missions";
|
||||||
import { OSMWay } from "@repo/db";
|
import { OSMWay } from "@repo/db";
|
||||||
|
import { usePannelStore } from "_store/pannelStore";
|
||||||
|
|
||||||
export const SearchElements = () => {
|
export const SearchElements = () => {
|
||||||
const {
|
const { searchElements, searchPopup, setSearchPopup, setContextMenu, openMissionMarker } =
|
||||||
searchElements,
|
useMapStore();
|
||||||
searchPopup,
|
const { missionFormValues, setMissionFormValues } = usePannelStore((state) => state);
|
||||||
setSearchPopup,
|
|
||||||
setContextMenu,
|
|
||||||
openMissionMarker,
|
|
||||||
} = useMapStore();
|
|
||||||
const missions = useQuery({
|
const missions = useQuery({
|
||||||
queryKey: ["missions"],
|
queryKey: ["missions"],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
@@ -59,27 +56,31 @@ export const SearchElements = () => {
|
|||||||
setContextMenu(null);
|
setContextMenu(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, [element.wayID]);
|
||||||
|
|
||||||
if (!element.nodes) return null;
|
if (!element.nodes) return null;
|
||||||
return (
|
return (
|
||||||
<Polygon
|
<Polygon
|
||||||
positions={element.nodes.map((node) => [node.lat, node.lon])}
|
positions={element.nodes.map((node) => [node.lat, node.lon])}
|
||||||
color={
|
color={searchPopup?.elementId === element.wayID || isActive ? "#ff4500" : "#46b7a3"}
|
||||||
searchPopup?.elementId === element.wayID || isActive
|
eventHandlers={{
|
||||||
? "#ff4500"
|
click: () => {
|
||||||
: "#46b7a3"
|
const addressOSMways = missionFormValues?.addressOSMways || [];
|
||||||
}
|
|
||||||
|
addressOSMways.push(JSON.parse(JSON.stringify(element)));
|
||||||
|
|
||||||
|
setMissionFormValues({
|
||||||
|
...missionFormValues,
|
||||||
|
addressOSMways,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}}
|
||||||
ref={ref}
|
ref={ref}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const SearchElementPopup = ({
|
const SearchElementPopup = ({ element }: { element: (typeof searchElements)[1] }) => {
|
||||||
element,
|
|
||||||
}: {
|
|
||||||
element: (typeof searchElements)[1];
|
|
||||||
}) => {
|
|
||||||
if (!searchPopup) return null;
|
if (!searchPopup) return null;
|
||||||
return (
|
return (
|
||||||
<Popup
|
<Popup
|
||||||
@@ -90,9 +91,7 @@ export const SearchElements = () => {
|
|||||||
>
|
>
|
||||||
<div className="bg-base-100/70 border border-rescuetrack w-[250px] text-white pointer-events-auto p-2">
|
<div className="bg-base-100/70 border border-rescuetrack w-[250px] text-white pointer-events-auto p-2">
|
||||||
<h3 className="text-lg font-bold">
|
<h3 className="text-lg font-bold">
|
||||||
{element.tags?.building === "yes"
|
{element.tags?.building === "yes" ? "Gebäude" : element.tags?.building}
|
||||||
? "Gebäude"
|
|
||||||
: element.tags?.building}
|
|
||||||
{!element.tags?.building && "unbekannt"}
|
{!element.tags?.building && "unbekannt"}
|
||||||
</h3>
|
</h3>
|
||||||
<p className="">
|
<p className="">
|
||||||
@@ -102,9 +101,7 @@ export const SearchElements = () => {
|
|||||||
{element.tags?.["addr:suburb"]} {element.tags?.["addr:postcode"]}
|
{element.tags?.["addr:suburb"]} {element.tags?.["addr:postcode"]}
|
||||||
</p>
|
</p>
|
||||||
<div className="flex flex-col gap-2 mt-2">
|
<div className="flex flex-col gap-2 mt-2">
|
||||||
<button className="btn bg-rescuetrack-highlight">
|
<button className="btn bg-rescuetrack-highlight">Zum Einsatz Hinzufügen</button>
|
||||||
Zum Einsatz Hinzufügen
|
|
||||||
</button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Popup>
|
</Popup>
|
||||||
@@ -141,12 +138,7 @@ export const SearchElements = () => {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
return null;
|
return null;
|
||||||
return (
|
return <SearchElement key={`mission-elem-${element.wayID}-${i}`} element={element} />;
|
||||||
<SearchElement
|
|
||||||
key={`mission-elem-${element.wayID}-${i}`}
|
|
||||||
element={element}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
})}
|
||||||
{searchPopup && (
|
{searchPopup && (
|
||||||
<Marker
|
<Marker
|
||||||
@@ -155,14 +147,10 @@ export const SearchElements = () => {
|
|||||||
icon={new L.DivIcon()}
|
icon={new L.DivIcon()}
|
||||||
opacity={0}
|
opacity={0}
|
||||||
>
|
>
|
||||||
{!searchPopupElement && (
|
{!searchPopupElement && <div className="w-20 border border-rescuetrack"></div>}
|
||||||
<div className="w-20 border border-rescuetrack"></div>
|
|
||||||
)}
|
|
||||||
</Marker>
|
</Marker>
|
||||||
)}
|
)}
|
||||||
{searchPopupElement && (
|
{searchPopupElement && <SearchElementPopup element={searchPopupElement} />}
|
||||||
<SearchElementPopup element={searchPopupElement} />
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user