맵 중복 생성 수정
iipbs_sn / build (push) Waiting to run

This commit is contained in:
yschoi
2025-05-12 19:03:33 +09:00
parent 1f6eab3fb2
commit c625101e7f
@@ -27,7 +27,7 @@ function Gis({ treeData = [], isSearch = false }) {
const [featureData,setFeatureData] = useState(null) // 선택된 피쳐 데이터
const [isSearchModalOpen, setIsSearchModalOpen] = useState(false); // SearchModal 열림 상태
const gisCore = useMemo(() => new GisApp.core({ targetId: mapRef.current }), []);
//const [treeData, setTreeData] = useState([]);
const mapInstanceRef = useRef(null); // 맵 생성 여부를 추적할 ref
const checkedLayerIds = useRef([]);
let gisMap = null;
const closePopup = () => {
@@ -50,6 +50,7 @@ function Gis({ treeData = [], isSearch = false }) {
useEffect(() => {
if (!mapRef.current) return;
if (mapInstanceRef.current) return; // 이미 생성된 맵이 있다면 중단
// EPSG:5179 등록
proj4.defs([
@@ -60,7 +61,7 @@ function Gis({ treeData = [], isSearch = false }) {
]);
register(proj4);
//맵 생성성
//맵 생성
const map = new OlMap({
layers: [gisCore.baseLayers['base'], gisCore.baseLayers['satellite']],
renderer: 'webgl',
@@ -104,10 +105,10 @@ function Gis({ treeData = [], isSearch = false }) {
gisCore.scaleControl();
gisCore.changeBaseLayer('base');
setMapObject({ map: map });
mapInstanceRef.current = map; // 생성 완료 플래그 설정
}, []);
useEffect(() => {
//if (!locgovCd) return null;
if (!treeData || treeData.length === 0) return;
gisCore.deleteAllOverlay();
@@ -146,7 +147,6 @@ function Gis({ treeData = [], isSearch = false }) {
}
}
return (
<>
<GisContext.Provider value={{gisCore, gisMap, treeData, checkedLayerIds}}>