Files
frontend/src/components/dashboard/inquiryPrivacy/technical-deputy/ShowProjectArea/ShowForbiddenBound.jsx
2025-12-17 14:53:19 +03:30

30 lines
831 B
JavaScript

import { useEffect, useRef } from "react";
import { FeatureGroup, useMap } from "react-leaflet";
const ShowForbiddenBound = ({ bound }) => {
const map = useMap();
const featureRef = useRef(null);
const safeFitBounds = (layer) => {
if (!layer || !map) return;
try {
const latLngs = layer.getLatLngs();
map.fitBounds(latLngs, {
paddingTopLeft: [20, 20],
paddingBottomRight: [20, 20],
});
} catch (e) {
console.warn("fitBounds failed:", e);
}
};
useEffect(() => {
bound?.editing?.disable();
featureRef.current.addLayer(bound);
safeFitBounds(bound);
}, []);
return <FeatureGroup ref={featureRef} />;
};
export default ShowForbiddenBound;