Added Context menu for building

This commit is contained in:
PxlLoewe
2025-04-08 17:53:06 -07:00
parent 5545e603bf
commit dc55b46385
5 changed files with 77 additions and 29 deletions

View File

@@ -5,11 +5,12 @@ import { Popup, useMap } from "react-leaflet";
export const ContextMenu = () => {
const map = useMap();
const { popup, setSearchElements, setPopup } = useMapStore();
const { popup, setSearchElements, setPopup, setSearchPopup } = useMapStore();
useEffect(() => {
map.on("contextmenu", (e) => {
setPopup({ isOpen: true, lat: e.latlng.lat, lng: e.latlng.lng });
setSearchPopup(undefined);
});
}, [popup]);
@@ -61,8 +62,8 @@ export const ContextMenu = () => {
`https://overpass-api.de/api/interpreter?data=${encodeURIComponent(`
[out:json];
(
way["building"](around:50, ${popup.lat}, ${popup.lng});
relation["building"](around:50, ${popup.lat}, ${popup.lng});
way["building"](around:100, ${popup.lat}, ${popup.lng});
relation["building"](around:100, ${popup.lat}, ${popup.lng});
);
out body;
>;
@@ -90,7 +91,6 @@ export const ContextMenu = () => {
};
}),
);
console.log(data);
}}
>
<Search size={20} />