added hightlight

This commit is contained in:
PxlLoewe
2025-04-08 09:45:21 -07:00
parent bde5de1969
commit 5545e603bf
3 changed files with 16 additions and 8 deletions

View File

@@ -5,7 +5,8 @@ import { Marker, Polygon, Polyline, Popup } from "react-leaflet";
import L from "leaflet"; import L from "leaflet";
export const SearchElements = () => { export const SearchElements = () => {
const { searchElements, searchPopup, setSearchPopup } = useMapStore(); const { searchElements, searchPopup, setSearchPopup, setPopup } =
useMapStore();
const poppupRef = useRef<LMarker>(null); const poppupRef = useRef<LMarker>(null);
useEffect(() => { useEffect(() => {
@@ -25,9 +26,7 @@ export const SearchElements = () => {
useEffect(() => { useEffect(() => {
if (ref.current) { if (ref.current) {
console.log(ref.current);
ref.current.on("click", () => { ref.current.on("click", () => {
console.log("click");
const center = ref.current.getBounds().getCenter(); const center = ref.current.getBounds().getCenter();
setSearchPopup({ setSearchPopup({
isOpen: true, isOpen: true,
@@ -35,7 +34,7 @@ export const SearchElements = () => {
lng: center.lng, lng: center.lng,
elementId: element.id, elementId: element.id,
}); });
console.log(element); setPopup(null);
}); });
} }
}, []); }, []);
@@ -44,12 +43,16 @@ export const SearchElements = () => {
<Polygon <Polygon
key={element.id} key={element.id}
positions={element.nodes.map((node) => [node.lat, node.lon])} positions={element.nodes.map((node) => [node.lat, node.lon])}
color="#46b7a3" color={searchPopup?.elementId === element.id ? "#ff4500" : "#46b7a3"}
ref={ref} ref={ref}
/> />
); );
}; };
console.log("searchPopup", searchPopup);
const searchPopupElement = searchElements.find(
(element) => element.id === searchPopup?.elementId,
);
console.log("searchPopupElement", searchPopupElement);
return ( return (
<> <>
{searchElements.map((element) => { {searchElements.map((element) => {
@@ -63,8 +66,8 @@ export const SearchElements = () => {
opacity={0} opacity={0}
> >
<Popup> <Popup>
<div className="absolute z-1000 opacity-100 pointer-events-auto w-[500px] text-white"> <div className="absolute z-1000 opacity-100 pointer-events-auto w-[250px] text-white border-rescuetrack border-2 bg-base-100/70">
<div className="bg-red-600 w-7 h-6">test</div> <div className="p-1 text-xl text-center">OSM-Element</div>
</div> </div>
</Popup> </Popup>
</Marker> </Marker>

View File

@@ -3,6 +3,11 @@
themes: dark, nord; themes: dark, nord;
} }
@theme {
--color-rescuetrack: #46b7a3;
--color-rescuetrack-highlight: #ff4500;
}
.leaflet-popup-tip-container { .leaflet-popup-tip-container {
display: none; display: none;
} }

Binary file not shown.