물재이용 지도보기 수정 2
This commit is contained in:
@@ -47,56 +47,7 @@ const Map = () => {
|
|||||||
|
|
||||||
// SearchModal, GisContent 등에서 호출
|
// SearchModal, GisContent 등에서 호출
|
||||||
const onFeatureFocus = (data: any) => {
|
const onFeatureFocus = (data: any) => {
|
||||||
console.log("page:onFeatureFocus");
|
console.log(data);
|
||||||
const map = gisMaps.current;
|
|
||||||
if (!map) {
|
|
||||||
console.warn("지도가 초기화되지 않았습니다.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 항상 같은 select 객체 사용
|
|
||||||
const select = GisApp.Module.select as any;
|
|
||||||
if (!select) return;
|
|
||||||
|
|
||||||
// 1. 기존 선택 초기화
|
|
||||||
select.resetSelectedFeature();
|
|
||||||
|
|
||||||
// 2. data가 OpenLayers Feature 인스턴스인지 확인
|
|
||||||
let foundFeature: any = null;
|
|
||||||
let featureId = data.fid;
|
|
||||||
const layerName = data.layerNm;
|
|
||||||
map
|
|
||||||
.getLayers()
|
|
||||||
.getArray()
|
|
||||||
.forEach((layer: any) => {
|
|
||||||
const source = layer.getSource?.();
|
|
||||||
if (source?.getFeatureById) {
|
|
||||||
const feature = source.getFeatureById(String(featureId).trim());
|
|
||||||
if (feature) foundFeature = feature;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3. 피처 선택
|
|
||||||
if (foundFeature) {
|
|
||||||
const geometry = foundFeature.getGeometry();
|
|
||||||
if (geometry) {
|
|
||||||
const extent = geometry.getExtent();
|
|
||||||
|
|
||||||
map.getView().fit(extent, {
|
|
||||||
duration: 300,
|
|
||||||
padding: [50, 50, 50, 50],
|
|
||||||
maxZoom: 16,
|
|
||||||
constrainResolution: true,
|
|
||||||
nearest: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// select.selectFeature(foundFeature, true);
|
|
||||||
} else {
|
|
||||||
console.warn("OpenLayers Feature를 찾을 수 없습니다:", data);
|
|
||||||
}
|
|
||||||
const currentId = data?.fid || data?.id || data?.ftrIdn;
|
|
||||||
const lastId = featureData?.fid || featureData?.id || featureData?.ftrIdn;
|
|
||||||
if (featureData && currentId === lastId) return; // 이전과 같으면 무시
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderDetailView = useCallback(
|
const renderDetailView = useCallback(
|
||||||
|
|||||||
@@ -225,7 +225,6 @@ export const SearchBar = ({
|
|||||||
|
|
||||||
//해당 시설물로 이동
|
//해당 시설물로 이동
|
||||||
const handleFeatureFocus = (data: any) => {
|
const handleFeatureFocus = (data: any) => {
|
||||||
console.log(data)
|
|
||||||
const map = gisMaps.current;
|
const map = gisMaps.current;
|
||||||
if (!map) {
|
if (!map) {
|
||||||
console.warn("지도가 초기화되지 않았습니다.");
|
console.warn("지도가 초기화되지 않았습니다.");
|
||||||
@@ -267,6 +266,8 @@ export const SearchBar = ({
|
|||||||
} else {
|
} else {
|
||||||
console.warn("Feature를 찾을 수 없습니다:", data);
|
console.warn("Feature를 찾을 수 없습니다:", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onFeatureFocus(foundFeature);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user