@@ -10,13 +10,21 @@ import "vue-simple-range-slider/css";
10
10
import { useRoute , useRouter } from ' vue-router' ;
11
11
import BarChart from " @/Component/BarChart.vue" ;
12
12
13
+ const goChat = (house ) => {
14
+ console .log (" 채팅버튼 선택" )
15
+ console .log (house .aptNm )
16
+ }
17
+
18
+
19
+
13
20
const map = ref (null ); // Kakao Map 객체
14
21
const polygons = ref ([]); // 생성된 폴리곤 객체 배열
15
22
const overlays = ref ([]); // 생성된 오버레이 객체 배열
16
23
const activePolygon = ref (null ); // 현재 활성화된 폴리곤
17
24
const level = ref (12 ); // 현재 줌 레벨
18
25
const detailMode = ref (" " ); // 현재 디테일 모드 ("do" 또는 "sig")
19
26
const centerData = ref ({}); // 센터 데이터를 저장할 객체
27
+
20
28
const clickedArea = ref (" " );
21
29
22
30
// Center 데이터 로드
@@ -29,7 +37,6 @@ const loadCenterData = async () => {
29
37
console .error (" Error loading center.json:" , error);
30
38
}
31
39
};
32
-
33
40
const sigData = ref ({}); // 시/군/구 경계 데이터 저장
34
41
35
42
const loadSigData = async () => {
@@ -69,7 +76,7 @@ const onLoadKakaoMap = async (mapRef) => {
69
76
Object .entries (centerData .value ).forEach (([areaName , areaData ]) => {
70
77
if (areaData .districts ) {
71
78
Object .entries (areaData .districts ).forEach (([districtName , coords ]) => {
72
- console .log (` Adding overlay for district: ${ districtName} at coords:` , coords);
79
+ // console.log(`Adding overlay for district: ${districtName} at coords:`, coords);
73
80
74
81
const content = document .createElement (" div" );
75
82
content .innerHTML = `
@@ -89,17 +96,15 @@ const onLoadKakaoMap = async (mapRef) => {
89
96
90
97
// 오버레이 클릭 이벤트 디버깅
91
98
content .addEventListener (" click" , () => {
92
- console .log (` ${ districtName} clicked!` );
93
- const overlayPosition = new kakao.maps.LatLng (coords .lat , coords .lng );
99
+ console .log (` ${ districtName} clicked!` );
94
100
95
- // 맵 이동 및 줌 레벨 감소
96
- map .value .panTo (overlayPosition);
97
- map .value .setLevel (map .value .getLevel () - 2 ); // 줌 레벨 감소
101
+ const overlayPosition = districtOverlay .getPosition (); // 오버레이의 위치 가져오기
98
102
99
- // 기존 폴리곤 제거 후 새 폴리곤 생성
100
- removePolygon ();
101
- displayDistrictPolygon (districtName, areaData .districts [districtName]);
102
- });
103
+ map .value .setCenter (overlayPosition);
104
+
105
+ // 줌 레벨 설정
106
+ map .value .setLevel (4 ); // 줌 레벨 설정
107
+ });
103
108
});
104
109
}
105
110
});
@@ -112,7 +117,6 @@ const loadPolygonData = async (path) => {
112
117
try {
113
118
const response = await axios .get (path);
114
119
const geojson = response .data ;
115
-
116
120
const areas = geojson .features .map ((unit ) => {
117
121
const coordinates = unit .geometry .coordinates [0 ];
118
122
const name = unit .properties .SIG_KOR_NM ;
@@ -153,6 +157,7 @@ const displayPolygon = (area) => {
153
157
});
154
158
155
159
overlays .value .push (overlay);
160
+ console .log (` Created overlay for ${ area .name } with content:` , area .name );
156
161
157
162
// 폴리곤 및 오버레이 이벤트 등록
158
163
kakao .maps .event .addListener (polygon, " mouseover" , () => {
@@ -168,24 +173,43 @@ const displayPolygon = (area) => {
168
173
});
169
174
170
175
kakao .maps .event .addListener (polygon, " click" , () => {
171
- console .log (` ${ area .name } clicked!` );
172
- clickedArea . value = area . name ;
173
- console . log ( ` =================> ${ area . name } ` )
174
- map .value .panTo ( new kakao.maps.LatLng ( center . lat , center . lng ));
175
- map . value . setLevel ( 9 );
176
-
177
- if ( activePolygon . value ) {
178
- activePolygon . value . setOptions ({ fillColor : " #fff " }) ;
176
+ console .log (` ${ area .name } clicked!` );
177
+
178
+ // 폴리곤 이름으로 오버레이 찾기
179
+ const overlay = overlays .value .find (( o ) => {
180
+ const overlayContent = o . getContent (); // HTML 노드 전체
181
+ if ( ! overlayContent) {
182
+ console . error ( ` Overlay content is undefined for area: ${ area . name } ` );
183
+ return false ;
179
184
}
180
185
181
- activePolygon .value = polygon;
182
- polygon .setOptions ({ fillColor: " #ffcccb" });
186
+ // HTML 콘텐츠에서 텍스트 추출
187
+ const overlayText = overlayContent .innerText ? .trim (); // innerText를 사용
188
+ console .log (` Checking overlay: "${ overlayText} " against "${ area .name } "` );
189
+ return overlayText === area .name ; // 텍스트 비교
183
190
});
191
+
192
+ if (overlay) {
193
+ const overlayPosition = overlay .getPosition (); // 오버레이의 위치 가져오기
194
+ console .log (` Setting center to overlay position: ${ overlayPosition} ` );
195
+ map .value .setCenter (overlayPosition); // 지도 중심 이동
196
+ map .value .setLevel (9 ); // 줌 레벨 설정
197
+ } else {
198
+ console .warn (` No overlay found for area: ${ area .name } ` );
199
+ }
200
+
201
+ // 폴리곤 색상 변경
202
+ if (activePolygon .value ) {
203
+ activePolygon .value .setOptions ({ fillColor: " #fff" });
204
+ }
205
+
206
+ activePolygon .value = polygon;
207
+ polygon .setOptions ({ fillColor: " #ffcccb" });
208
+ });
209
+
184
210
};
185
211
186
212
const displayDistrictPolygon = (name , coords ) => {
187
- console .log (` Creating polygon for district: ${ name} ` );
188
- console .log (` Coordinates received:` , coords); // coords 디버깅
189
213
190
214
// coords가 올바른 배열인지 확인
191
215
if (! coords || ! Array .isArray (coords) || coords .length === 0 ) {
@@ -207,7 +231,6 @@ const displayDistrictPolygon = (name, coords) => {
207
231
polygon .setMap (map .value );
208
232
polygons .value .push (polygon);
209
233
210
- console .log (` Polygon created for district: ${ name} ` );
211
234
};
212
235
213
236
// 폴리곤 및 오버레이 제거
@@ -225,7 +248,6 @@ const removeOverlays = () => {
225
248
onMounted (async () => {
226
249
await loadCenterData ();
227
250
});
228
-
229
251
// 필터 버튼
230
252
const filters = [" 가격" , " 면적" , " 사용승인일" , " 층수" ];
231
253
@@ -241,7 +263,7 @@ const fetchData = async (params) => {
241
263
};
242
264
243
265
onMounted (async () => {
244
-
266
+
245
267
console .log (route .params );
246
268
console .log (" Route query:" , route .query );
247
269
console .log (" onMounted 시작" )
@@ -297,11 +319,11 @@ const toggleSlider = (filter) => {
297
319
298
320
const applyFilter1 = async () => {
299
321
300
- const query1 = { buildingUse: ' 아파트' ,
322
+ const query1 = { buildingUse: ' 아파트' ,
301
323
fromArea: state.면적[0 ],
302
324
toArea: state.면적[1 ],
303
325
keyword: state.검색어 }
304
-
326
+
305
327
const queryString1 = new URLSearchParams (query1).toString ();
306
328
await fetchData (queryString1); // 데이터 로드
307
329
};
@@ -344,7 +366,7 @@ const findDealsByAptseq = async (aptSeq) => {
344
366
try {
345
367
console .log (` Fetching deals for aptSeq: ${ aptSeq} ` );
346
368
await houseInfoStore .fetchHouseDeals (aptSeq); // Pinia 스토어 호출
347
-
369
+
348
370
} catch (error) {
349
371
console .error (" 거래 정보를 가져오는데 실패했습니다:" , error);
350
372
}
@@ -361,12 +383,12 @@ class TrieNode {
361
383
this .isEndOfWord = false ;
362
384
}
363
385
}
364
-
386
+
365
387
class Trie {
366
388
constructor () {
367
389
this .root = new TrieNode ();
368
390
}
369
-
391
+
370
392
insert (word ) {
371
393
let node = this .root ;
372
394
for (const char of word) {
@@ -377,7 +399,7 @@ class TrieNode {
377
399
}
378
400
node .isEndOfWord = true ;
379
401
}
380
-
402
+
381
403
search (prefix ) {
382
404
let node = this .root ;
383
405
for (const char of prefix) {
@@ -388,7 +410,7 @@ class TrieNode {
388
410
}
389
411
return this ._collectWords (node, prefix);
390
412
}
391
-
413
+
392
414
_collectWords (node , prefix ) {
393
415
const results = [];
394
416
if (node .isEndOfWord ) {
@@ -400,7 +422,7 @@ class TrieNode {
400
422
return results;
401
423
}
402
424
}
403
-
425
+
404
426
const houseNames = ref ([]);
405
427
const searchQuery = ref (" " );
406
428
const filteredNames = ref ([]);
@@ -452,7 +474,7 @@ const updateSearchResults = () => {
452
474
<!-- 검색 창-->
453
475
< div class = " relative w-[370px] ml-4 mr-2 " >
454
476
< input
455
- v- model= " searchQuery"
477
+ v- model= " searchQuery"
456
478
type= " text"
457
479
@input= " updateSearchResults"
458
480
placeholder= " 찾고자하는 아파트 이름을 입력하세요"
@@ -566,7 +588,7 @@ const updateSearchResults = () => {
566
588
< / div>
567
589
< / div>
568
590
< / div>
569
- <!-- 필요한 필터 수 만큼 반복 -->
591
+ <!-- 필요한 필터 수 만큼 반복 -->
570
592
< button type= " button" class = " relative inline-block text-left ml-2 h-8 px-2 py-2 bg-white border border-gray-300 shadow-sm focus:ring-indigo-500" >
571
593
< svg class = " h-4 w-4" xmlns= " http://www.w3.org/2000/svg" fill= " currentColor" viewBox= " 0 0 24 24" @click= " initFilter" >
572
594
< path d= " M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z" / >
@@ -588,7 +610,7 @@ const updateSearchResults = () => {
588
610
< div v- for = " name in houseNames" : key= " name.aptSeq" >
589
611
{{ name .aptNm }}
590
612
< / div>
591
- < / div>
613
+ < / div>
592
614
< div v- for = " house in houseInfos" : key= " house.id" >
593
615
< CardView
594
616
: jibun= " house.jibun"
@@ -600,7 +622,7 @@ const updateSearchResults = () => {
600
622
: legalName= " house.dongName"
601
623
: minPropertyPrice= " house.minPrice"
602
624
: maxPropertyPrice= " house.maxPrice"
603
- @click= " handleCardClick(house)"
625
+ @click= " handleCardClick(house)"
604
626
/ >
605
627
<!-- 오른쪽 뷰 -->
606
628
< div
@@ -625,7 +647,7 @@ const updateSearchResults = () => {
625
647
< img src= " @/assets/icons/heart.svg" width= " 20px" >
626
648
< / button>
627
649
< button class = " pt-1" >
628
- < img src= " @/assets/icons/chat_icon.png" width= " 20px" >
650
+ < img src= " @/assets/icons/chat_icon.png" width= " 20px" @click = goChat (house) >
629
651
< / button>
630
652
< / div>
631
653
< / div>
@@ -644,7 +666,7 @@ const updateSearchResults = () => {
644
666
{{ house .gugunName }}
645
667
{{ house .dongName }}
646
668
{{ house .jibun }}
647
- < / span>
669
+ < / span>
648
670
< / div>
649
671
< div class = " flex flex-row mb-2" >
650
672
< div class = " flex flex-row mr-2 " >
@@ -676,7 +698,7 @@ const updateSearchResults = () => {
676
698
< span class = " text-left text-lg font-PretendardSemiBold mt-4 border-b-4 px-2 py-1" >
677
699
거래정보
678
700
< / span>
679
-
701
+
680
702
< table class = " min-w-full border-collapse border border-gray-200 mt-4" >
681
703
< thead>
682
704
< tr class = " bg-blue-100 text-sm" >
@@ -697,8 +719,8 @@ const updateSearchResults = () => {
697
719
< / tbody>
698
720
< / table>
699
721
< div>
700
-
701
- < / div>
722
+
723
+ < / div>
702
724
< / div>
703
725
< / div>
704
726
< / div>
@@ -714,7 +736,7 @@ const updateSearchResults = () => {
714
736
style= " width: 100%; height: 100%;"
715
737
class = " absolute z-0 " >
716
738
< div v- for = " house in houseInfos" : key= " house.id" >
717
- < KakaoMapMarker
739
+ < KakaoMapMarker
718
740
: lat= " parseFloat(house.latitude)"
719
741
: lng= " parseFloat(house.longitude)" >
720
742
< / KakaoMapMarker>
@@ -741,4 +763,4 @@ div {
741
763
pointer- events: auto; /* 오버레이가 클릭 가능하도록 */
742
764
z- index: 1000 ; /* 오버레이가 다른 요소 위에 표시되도록 */
743
765
}
744
- < / style>
766
+ < / style>
0 commit comments