slick-address-kr 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/API-KEY-GUIDE.md +428 -0
- package/AUTOCOMPLETE-GUIDE.md +399 -0
- package/HOW-TO-USE.md +416 -0
- package/LICENSE +21 -0
- package/README.ko.md +88 -0
- package/README.md +434 -0
- package/config.example.js +16 -0
- package/dist/address-finder.d.ts +68 -0
- package/dist/address-finder.js +262 -0
- package/dist/api-client.d.ts +25 -0
- package/dist/api-client.js +79 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/styles.css +279 -0
- package/dist/types.d.ts +83 -0
- package/dist/types.js +1 -0
- package/index.html +85 -0
- package/korean-address-finder.js +360 -0
- package/package.json +58 -0
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# 자동완성 기능 가이드
|
|
2
|
+
|
|
3
|
+
다음 주소 API와 동일한 자동완성 기능이 추가되었습니다!
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ✨ 자동완성 기능이란?
|
|
8
|
+
|
|
9
|
+
타이핑하는 즉시 검색 결과가 나타나는 기능입니다.
|
|
10
|
+
|
|
11
|
+
### 다음 주소 API와 동일한 경험
|
|
12
|
+
|
|
13
|
+
- ✅ 2글자 이상 입력 시 자동 검색
|
|
14
|
+
- ✅ 300ms 디바운스 적용 (과도한 API 호출 방지)
|
|
15
|
+
- ✅ 입력 중지 시 자동으로 검색
|
|
16
|
+
- ✅ 검색 버튼 클릭 불필요
|
|
17
|
+
- ✅ 외부 클릭 시 결과 닫기
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 🚀 기본 사용 (자동완성 켜짐)
|
|
22
|
+
|
|
23
|
+
자동완성은 **기본적으로 활성화**되어 있습니다!
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const finder = new KoreanAddressFinder({
|
|
27
|
+
containerId: 'address-finder',
|
|
28
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
29
|
+
// autocomplete는 기본값이 true
|
|
30
|
+
onSelect: function(address) {
|
|
31
|
+
console.log(address);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
finder.init();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 작동 방식
|
|
39
|
+
|
|
40
|
+
1. **입력 시작**: "판교" 입력
|
|
41
|
+
2. **300ms 대기**: 더 입력할지 기다림
|
|
42
|
+
3. **자동 검색**: 추가 입력 없으면 자동으로 API 호출
|
|
43
|
+
4. **결과 표시**: 드롭다운으로 결과 표시
|
|
44
|
+
5. **선택**: 원하는 주소 클릭
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## ⚙️ 옵션 설정
|
|
49
|
+
|
|
50
|
+
### 자동완성 끄기
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
const finder = new KoreanAddressFinder({
|
|
54
|
+
containerId: 'address-finder',
|
|
55
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
56
|
+
autocomplete: false, // 자동완성 비활성화
|
|
57
|
+
onSelect: function(address) {
|
|
58
|
+
console.log(address);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
finder.init();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
자동완성을 끄면:
|
|
66
|
+
- 검색 버튼을 클릭하거나
|
|
67
|
+
- 엔터키를 눌러야 검색됩니다
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
### 최소 검색 글자 수 변경
|
|
72
|
+
|
|
73
|
+
```javascript
|
|
74
|
+
const finder = new KoreanAddressFinder({
|
|
75
|
+
containerId: 'address-finder',
|
|
76
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
77
|
+
minLength: 3, // 3글자 이상부터 검색 (기본값: 2)
|
|
78
|
+
onSelect: function(address) {
|
|
79
|
+
console.log(address);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
finder.init();
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### 디바운스 시간 조정
|
|
89
|
+
|
|
90
|
+
현재는 300ms로 고정되어 있습니다. 필요시 코드를 수정할 수 있습니다:
|
|
91
|
+
|
|
92
|
+
```javascript
|
|
93
|
+
// korean-address-finder.js 파일에서
|
|
94
|
+
setTimeout(() => {
|
|
95
|
+
this.search(keyword);
|
|
96
|
+
}, 300); // ← 이 값을 변경
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**권장 값:**
|
|
100
|
+
- 빠른 응답: 200ms
|
|
101
|
+
- 기본: 300ms (권장)
|
|
102
|
+
- API 절약: 500ms
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## 💡 사용 예제
|
|
107
|
+
|
|
108
|
+
### 예제 1: 기본 자동완성
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<div id="address-finder"></div>
|
|
112
|
+
|
|
113
|
+
<script src="config.js"></script>
|
|
114
|
+
<script src="korean-address-finder.js"></script>
|
|
115
|
+
<script>
|
|
116
|
+
const finder = new KoreanAddressFinder({
|
|
117
|
+
containerId: 'address-finder',
|
|
118
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
119
|
+
// 자동완성 기본 활성화
|
|
120
|
+
onSelect: function(address) {
|
|
121
|
+
console.log('선택:', address);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
finder.init();
|
|
126
|
+
</script>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**테스트:**
|
|
130
|
+
1. "판교역로" 입력 시작
|
|
131
|
+
2. "판교" 입력 후 잠시 대기
|
|
132
|
+
3. 자동으로 결과 표시!
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
### 예제 2: 폼과 연동
|
|
137
|
+
|
|
138
|
+
```html
|
|
139
|
+
<form id="address-form">
|
|
140
|
+
<input type="text" id="zipcode" readonly placeholder="우편번호">
|
|
141
|
+
<input type="text" id="address1" readonly placeholder="주소">
|
|
142
|
+
<input type="text" id="address2" placeholder="상세주소">
|
|
143
|
+
|
|
144
|
+
<!-- 자동완성 주소 검색 -->
|
|
145
|
+
<div id="address-finder"></div>
|
|
146
|
+
|
|
147
|
+
<button type="submit">저장</button>
|
|
148
|
+
</form>
|
|
149
|
+
|
|
150
|
+
<script src="config.js"></script>
|
|
151
|
+
<script src="korean-address-finder.js"></script>
|
|
152
|
+
<script>
|
|
153
|
+
const finder = new KoreanAddressFinder({
|
|
154
|
+
containerId: 'address-finder',
|
|
155
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
156
|
+
autocomplete: true, // 자동완성
|
|
157
|
+
onSelect: function(address) {
|
|
158
|
+
// 폼에 자동 입력
|
|
159
|
+
document.getElementById('zipcode').value = address.zipCode;
|
|
160
|
+
document.getElementById('address1').value = address.roadAddress;
|
|
161
|
+
document.getElementById('address2').focus(); // 상세주소로 포커스
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
finder.init();
|
|
166
|
+
</script>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**사용자 경험:**
|
|
170
|
+
1. 주소 검색창에 "강남구 테헤" 입력
|
|
171
|
+
2. 자동으로 "강남구 테헤란로" 결과 표시
|
|
172
|
+
3. 원하는 주소 클릭
|
|
173
|
+
4. 우편번호, 주소가 자동으로 입력됨
|
|
174
|
+
5. 상세주소 입력만 하면 완료!
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
### 예제 3: 자동완성 비활성화 (수동 검색)
|
|
179
|
+
|
|
180
|
+
```javascript
|
|
181
|
+
const finder = new KoreanAddressFinder({
|
|
182
|
+
containerId: 'address-finder',
|
|
183
|
+
apiKey: window.CONFIG.jusoApiKey,
|
|
184
|
+
autocomplete: false, // 자동완성 끔
|
|
185
|
+
onSelect: function(address) {
|
|
186
|
+
console.log(address);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
finder.init();
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**사용 방식:**
|
|
194
|
+
- 주소 입력 후 검색 버튼 클릭
|
|
195
|
+
- 또는 엔터키 입력
|
|
196
|
+
- 타이핑만으로는 검색 안 됨
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 🎯 자동완성 vs 수동 검색
|
|
201
|
+
|
|
202
|
+
### 자동완성 모드 (기본)
|
|
203
|
+
|
|
204
|
+
**장점:**
|
|
205
|
+
- ✅ 빠른 검색
|
|
206
|
+
- ✅ 편리한 사용자 경험
|
|
207
|
+
- ✅ 다음 주소 API와 동일한 느낌
|
|
208
|
+
|
|
209
|
+
**단점:**
|
|
210
|
+
- ⚠️ API 호출 횟수 증가
|
|
211
|
+
- ⚠️ 네트워크 트래픽 증가
|
|
212
|
+
|
|
213
|
+
**추천 대상:**
|
|
214
|
+
- 일반 웹사이트
|
|
215
|
+
- 사용자 경험 중시
|
|
216
|
+
- API 호출 제한이 넉넉한 경우
|
|
217
|
+
|
|
218
|
+
---
|
|
219
|
+
|
|
220
|
+
### 수동 검색 모드
|
|
221
|
+
|
|
222
|
+
**장점:**
|
|
223
|
+
- ✅ API 호출 최소화
|
|
224
|
+
- ✅ 네트워크 트래픽 절약
|
|
225
|
+
- ✅ 정확한 검색어로만 검색
|
|
226
|
+
|
|
227
|
+
**단점:**
|
|
228
|
+
- ⚠️ 버튼 클릭 또는 엔터 필요
|
|
229
|
+
- ⚠️ 다소 불편할 수 있음
|
|
230
|
+
|
|
231
|
+
**추천 대상:**
|
|
232
|
+
- 내부 시스템
|
|
233
|
+
- API 호출 제한이 있는 경우
|
|
234
|
+
- 트래픽 절약이 중요한 경우
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## 🔧 성능 최적화
|
|
239
|
+
|
|
240
|
+
### 1. 디바운스 적용 (이미 적용됨)
|
|
241
|
+
|
|
242
|
+
타이핑이 완전히 멈춘 후 검색합니다.
|
|
243
|
+
|
|
244
|
+
```javascript
|
|
245
|
+
// 300ms 대기 후 검색
|
|
246
|
+
clearTimeout(this.debounceTimer);
|
|
247
|
+
this.debounceTimer = setTimeout(() => {
|
|
248
|
+
this.search(keyword);
|
|
249
|
+
}, 300);
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
### 2. 최소 길이 체크 (이미 적용됨)
|
|
253
|
+
|
|
254
|
+
2글자 미만은 검색하지 않습니다.
|
|
255
|
+
|
|
256
|
+
```javascript
|
|
257
|
+
if (keyword.length < this.minLength) {
|
|
258
|
+
resultsDiv.style.display = 'none';
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### 3. 중복 검색 방지 (선택사항)
|
|
264
|
+
|
|
265
|
+
동일한 키워드는 다시 검색하지 않습니다.
|
|
266
|
+
|
|
267
|
+
```javascript
|
|
268
|
+
// korean-address-finder.js에 추가
|
|
269
|
+
constructor(options = {}) {
|
|
270
|
+
// ...
|
|
271
|
+
this.lastKeyword = ''; // 마지막 검색어
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
search(keyword) {
|
|
275
|
+
// 중복 검색 방지
|
|
276
|
+
if (keyword === this.lastKeyword) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
this.lastKeyword = keyword;
|
|
280
|
+
|
|
281
|
+
// 검색 실행...
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 🎨 자동완성 UI 커스터마이징
|
|
288
|
+
|
|
289
|
+
### 결과 드롭다운 스타일 변경
|
|
290
|
+
|
|
291
|
+
```html
|
|
292
|
+
<style>
|
|
293
|
+
/* 결과 목록 배경색 */
|
|
294
|
+
.kaf-results {
|
|
295
|
+
background-color: #ffffff !important;
|
|
296
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/* 결과 항목 호버 */
|
|
300
|
+
.kaf-result-item:hover {
|
|
301
|
+
background-color: #e3f2fd !important;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/* 로딩 텍스트 */
|
|
305
|
+
.kaf-loading {
|
|
306
|
+
color: #4a90e2 !important;
|
|
307
|
+
}
|
|
308
|
+
</style>
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## 📱 모바일 최적화
|
|
314
|
+
|
|
315
|
+
자동완성은 모바일에서도 완벽하게 작동합니다!
|
|
316
|
+
|
|
317
|
+
- ✅ 터치 입력 지원
|
|
318
|
+
- ✅ 가상 키보드와 호환
|
|
319
|
+
- ✅ 스크롤 가능한 결과 목록
|
|
320
|
+
- ✅ 외부 터치로 닫기
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 🐛 문제 해결
|
|
325
|
+
|
|
326
|
+
### 자동완성이 너무 느려요
|
|
327
|
+
|
|
328
|
+
**해결책 1:** 디바운스 시간 줄이기
|
|
329
|
+
```javascript
|
|
330
|
+
// korean-address-finder.js 파일에서
|
|
331
|
+
setTimeout(() => {
|
|
332
|
+
this.search(keyword);
|
|
333
|
+
}, 200); // 300ms → 200ms
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
**해결책 2:** 최소 글자 수 늘리기
|
|
337
|
+
```javascript
|
|
338
|
+
const finder = new KoreanAddressFinder({
|
|
339
|
+
minLength: 3, // 2 → 3
|
|
340
|
+
// ...
|
|
341
|
+
});
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
---
|
|
345
|
+
|
|
346
|
+
### 자동완성이 너무 자주 호출돼요
|
|
347
|
+
|
|
348
|
+
**해결책 1:** 디바운스 시간 늘리기
|
|
349
|
+
```javascript
|
|
350
|
+
setTimeout(() => {
|
|
351
|
+
this.search(keyword);
|
|
352
|
+
}, 500); // 300ms → 500ms
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
**해결책 2:** 자동완성 끄기
|
|
356
|
+
```javascript
|
|
357
|
+
const finder = new KoreanAddressFinder({
|
|
358
|
+
autocomplete: false,
|
|
359
|
+
// ...
|
|
360
|
+
});
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
### 결과가 안 닫혀요
|
|
366
|
+
|
|
367
|
+
**원인:** 외부 클릭 이벤트 충돌
|
|
368
|
+
|
|
369
|
+
**해결:** 다른 클릭 이벤트와 충돌하지 않도록 코드 확인
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## 🎉 완성!
|
|
374
|
+
|
|
375
|
+
이제 다음 주소 API와 동일한 자동완성 기능을 사용할 수 있습니다!
|
|
376
|
+
|
|
377
|
+
**테스트해보세요:**
|
|
378
|
+
|
|
379
|
+
1. 브라우저에서 열기
|
|
380
|
+
```
|
|
381
|
+
http://localhost:8000/index.html
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
2. 검색창에 입력 시작
|
|
385
|
+
- "판교" 입력
|
|
386
|
+
- 잠시 대기 (300ms)
|
|
387
|
+
- 자동으로 결과 표시!
|
|
388
|
+
|
|
389
|
+
3. 원하는 주소 클릭
|
|
390
|
+
|
|
391
|
+
**완료!** 🚀
|
|
392
|
+
|
|
393
|
+
---
|
|
394
|
+
|
|
395
|
+
## 📚 추가 문서
|
|
396
|
+
|
|
397
|
+
- [기본 사용 가이드](./HOW-TO-USE.md)
|
|
398
|
+
- [API 키 관리](./API-KEY-GUIDE.md)
|
|
399
|
+
- [전체 문서](./README.md)
|