index.html
29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>Modern Business - Start Bootstrap Template</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="assets/favicon.ico" />
<!-- Bootstrap icons-->
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css" rel="stylesheet" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
<script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=c71c02e15245260c3350614980ba87c8&libraries=services,clusterer,drawing"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script>
// 고속도로 선택 함수
function showline(lineNumber){
// 이 위치에 이전에 켜져있는 map을 지우는 기능 넣어야해 ...
var container = document.getElementById('map'); //지도를 담을 영역의 DOM 레퍼런스
var options = { //지도를 생성할 때 필요한 기본 옵션
center: new kakao.maps.LatLng(36.137944,128.044905), //지도의 중심좌표.
level: 13 //지도의 레벨(확대, 축소 정도)
};
var map = new kakao.maps.Map(container, options); //지도 생성 및 객체 리턴
line = []
//csv 파일에서 이정 좌표 가져와서 line 변수에 저장
$.ajax({
url: 'data.csv',
dataType: 'text',
async: false,
success: function(data){
var allRows = data.split(/\r?\n|\r/);
for (var singleRow = 0; singleRow < allRows.length; singleRow++) {
var rowCells = allRows[singleRow].split(',');
if(rowCells[0] == lineNumber){
line.push(new kakao.maps.LatLng(rowCells[3],rowCells[4]))
}
}
}
});
var polyline = new kakao.maps.Polyline({
path: line, // 선을 구성하는 좌표배열 입니다
strokeWeight: 5, // 선의 두께 입니다
strokeColor: '#FF4500', // 선의 색깔입니다
strokeOpacity: 0.7, // 선의 불투명도 입니다 1에서 0 사이의 값이며 0에 가까울수록 투명합니다
strokeStyle: 'solid' // 선의 스타일입니다
});
polyline.setMap(map)
var userData;
// 1번 페이지
$.ajax({
url: "http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=1",
async:false,
success: function(data){
//변수 설정
userData = data;
},
})
var markers = [];
var infomations =[];
var result_str="";
var routeCode = "";
var svarAddr = "";
var rest_name = "";
var data_count = userData["list"].length // 데이터 개수 얻기
for (var i =0; i<data_count; i++){
routeCode = JSON.stringify(userData["list"][i]["routeCode"]);
svarAddr = JSON.stringify(userData["list"][i]["svarAddr"]);
rest_name = JSON.stringify(userData["list"][i]["serviceAreaName"]);
if(routeCode.substring(1,5) === lineNumber){ // 고속도로 코드가 같다면
var geocoder = new kakao.maps.services.Geocoder();
// 주소로 좌표를 검색합니다
geocoder.addressSearch(svarAddr, function(result, status) {
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
//위치 저장
var coords = new kakao.maps.LatLng(result[0].y, result[0].x);
var marker = new kakao.maps.Marker({
position: coords,
map: map
});
markers.push(marker); // markers 로 정상적 push 수행 안됨
}
});
}
}
alert(markers.length)
/*
// 2번 페이지
$.ajax({
url: "http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=2",
success: function(data){
var userData = JSON.stringify(data);
var result_str="";
var routeCode = "";
var svarAddr = "";
var rest_name = "";
var count = data["list"].length;
for (var i =0; i<count; i++){
routeCode = JSON.stringify(data["list"][i]["routeCode"]);
svarAddr = JSON.stringify(data["list"][i]["svarAddr"]);
rest_name = JSON.stringify(data["list"][i]["serviceAreaName"]);
var infowindow = new kakao.maps.InfoWindow({
content: rest_name
});
if(routeCode.substring(1,5) === lineNumber){
document.getElementById("testArea").innerHTML += routeCode.substring(1,5)+ " ";
var geocoder = new kakao.maps.services.Geocoder();
// 주소로 좌표를 검색합니다
geocoder.addressSearch(svarAddr, function(result, status) {
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
var coords = new kakao.maps.LatLng(result[0].y, result[0].x);
var temp = i
// 결과값으로 받은 위치를 마커로 표시합니다
var marker = new kakao.maps.Marker({
map: map,
position: coords,
});
// 인포윈도우로 장소에 대한 설명을 표시합니다
kakao.maps.event.addListener(marker, 'mouseover', makeOverListener(map, marker, infowindow));
kakao.maps.event.addListener(marker, 'mouseout', makeOutListener(infowindow));
document.getElementById("position_ex").innerHTML = svarAddr;
}
});
}
}
},
})
// 3번 페이지
$.ajax({
url: "http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=3",
success: function(data){
var userData = JSON.stringify(data);
var result_str="";
var routeCode = "";
var svarAddr = "";
var rest_name = "";
var count = data["list"].length;
for (var i =0; i<count; i++){
routeCode = JSON.stringify(data["list"][i]["routeCode"]);
svarAddr = JSON.stringify(data["list"][i]["svarAddr"]);
rest_name = JSON.stringify(data["list"][i]["serviceAreaName"]);
var infowindow = new kakao.maps.InfoWindow({
content: rest_name
});
if(routeCode.substring(1,5) === lineNumber){
document.getElementById("testArea").innerHTML += routeCode.substring(1,5)+ " ";
var geocoder = new kakao.maps.services.Geocoder();
// 주소로 좌표를 검색합니다
geocoder.addressSearch(svarAddr, function(result, status) {
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
var coords = new kakao.maps.LatLng(result[0].y, result[0].x);
var temp = i
// 결과값으로 받은 위치를 마커로 표시합니다
var marker = new kakao.maps.Marker({
map: map,
position: coords,
});
// 인포윈도우로 장소에 대한 설명을 표시합니다
kakao.maps.event.addListener(marker, 'mouseover', makeOverListener(map, marker, infowindow));
kakao.maps.event.addListener(marker, 'mouseout', makeOutListener(infowindow));
document.getElementById("position_ex").innerHTML = svarAddr;
}
});
}
}
},
})
*/
}
</script>
</head>
<body class="d-flex flex-column h-100">
<main class="flex-shrink-0">
<!-- Navigation-->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container px-5">
<a class="navbar-brand" href="/">휴게소 정보</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="/">Home</a></li>
<li class="nav-item"><a class="nav-link" href="/menu">휴게소 메뉴</a></li>
<li class="nav-item"><a class="nav-link" href="/weather">날씨</a></li>
<li class="nav-item"><a class="nav-link" href="/lpg">LPG</a></li>
<li class="nav-item"><a class="nav-link" href="faq.html">FAQ</a></li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownBlog" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Blog</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownBlog">
<li><a class="dropdown-item" href="blog-home.html">Blog Home</a></li>
<li><a class="dropdown-item" href="blog-post.html">Blog Post</a></li>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdownLogin" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">Login</a>
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownLogin">
<li><a class="dropdown-item" href="/login">Login</a></li>
<li><a class="dropdown-item" href="/signup">Sign-up</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Header-->
<header class="bg-dark py-5">
<div class="container px-5">
<div class="row gx-5 align-items-center justify-content-center">
<div class="col-lg-8 col-xl-7 col-xxl-6">
<div class="my-5 text-center text-xl-start">
<h1 class="display-5 fw-bolder text-white mb-2">각 고속도로별 휴게소 지도 오픈 API 삽입 >></h1>
<p class="lead fw-normal text-white-50 mb-4">적당히 텍스트 삽입</p>
<div class="dropdown">
<button class ="btn btn-primary dropdown-toggle " data-bs-toggle="dropdown">
고속도로 선택
</button>
<div class ="dropdown-menu">
<a class="dropdown-item" onclick="showline('0010')">경부선</a>
<a class="dropdown-item" onclick="showline('0550')">중앙선</a>
<a class="dropdown-item" onclick="showline('0500')">영동선</a>
</div>
</div>
</div>
</div>
<script>
// 지도 구현 부분
</script>
<div id="map" style="width:600px;height:400px;"></div>
<script>
var container = document.getElementById('map'); //지도를 담을 영역의 DOM 레퍼런스
var options = { //지도를 생성할 때 필요한 기본 옵션
center: new kakao.maps.LatLng(36.137944,128.044905), //지도의 중심좌표.
level: 13 //지도의 레벨(확대, 축소 정도)
};
var map = new kakao.maps.Map(container, options); //지도 생성 및 객체 리턴
// 마커표시
var geocoder = new kakao.maps.services.Geocoder();
// 휴게소 주소 입력시, 마커 표시 및 이동
geocoder.addressSearch('경기도 용인시 고림동9', function(result, status) {
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
var coords = new kakao.maps.LatLng(result[0].y, result[0].x);
// 결과값으로 받은 위치를 마커로 표시합니다
var marker = new kakao.maps.Marker({
map: map,
position: coords
});
// 지도의 중심을 결과값으로 받은 위치로 이동시킵니다
map.setLevel(4);
map.setCenter(new kakao.maps.LatLng(result[0].y, result[0].x));
}
});
</script>
</div>
</div>
</header>
<!-- Features section-->
<section class="py-5" id="features">
<div class="container px-5 my-5">
<div class="row gx-5">
<div class="col-lg-4 mb-5 mb-lg-0"><h2 class="fw-bolder mb-0">여기는 나중에 추천메뉴 넣으면..?</h2></div>
<div class="col-lg-8">
<div class="row gx-5 row-cols-1 row-cols-md-2">
<div class="col mb-5 h-100">
<div class="feature bg-primary bg-gradient text-white rounded-3 mb-3"><i class="bi bi-collection"></i></div>
<h2 class="h5">Featured title</h2>
<p class="mb-0">Paragraph of text beneath the heading to explain the heading. Here is just a bit more text.</p>
</div>
<div class="col mb-5 h-100">
<div class="feature bg-primary bg-gradient text-white rounded-3 mb-3"><i class="bi bi-building"></i></div>
<h2 class="h5">Featured title</h2>
<p class="mb-0">Paragraph of text beneath the heading to explain the heading. Here is just a bit more text.</p>
</div>
<div class="col mb-5 mb-md-0 h-100">
<div class="feature bg-primary bg-gradient text-white rounded-3 mb-3"><i class="bi bi-toggles2"></i></div>
<h2 class="h5">Featured title</h2>
<p class="mb-0">Paragraph of text beneath the heading to explain the heading. Here is just a bit more text.</p>
</div>
<div class="col h-100">
<div class="feature bg-primary bg-gradient text-white rounded-3 mb-3"><i class="bi bi-toggles2"></i></div>
<h2 class="h5">Featured title</h2>
<p class="mb-0">Paragraph of text beneath the heading to explain the heading. Here is just a bit more text.</p>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- Testimonial section-->
<div class="py-5 bg-light">
<div class="container px-5 my-5">
<div class="row gx-5 justify-content-center">
<div class="col-lg-10 col-xl-7">
<div class="text-center">
<div class="fs-4 mb-4 fst-italic" id ="testArea">이 아래는 그다지 필요하지 않을것 같으니 일단 두고 나중에 전부삭제</div>
<div class="d-flex align-items-center justify-content-center">
<img class="rounded-circle me-3" src="https://dummyimage.com/40x40/ced4da/6c757d" alt="..." />
<div class="fw-bold">
Tom Ato
<span class="fw-bold text-primary mx-1">/</span>
CEO, Pomodoro
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Blog preview section-->
<section class="py-5">
<div class="container px-5 my-5">
<div class="row gx-5 justify-content-center">
<div class="col-lg-8 col-xl-6">
<div class="text-center">
<h2 class="fw-bolder">From our blog</h2>
<p class="lead fw-normal text-muted mb-5">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Eaque fugit ratione dicta mollitia. Officiis ad.</p>
</div>
</div>
</div>
<div class="row gx-5">
<div class="col-lg-4 mb-5">
<div class="card h-100 shadow border-0">
<img class="card-img-top" src="https://dummyimage.com/600x350/ced4da/6c757d" alt="..." />
<div class="card-body p-4">
<div class="badge bg-primary bg-gradient rounded-pill mb-2">News</div>
<a class="text-decoration-none link-dark stretched-link" href="#!"><h5 class="card-title mb-3">Blog post title</h5></a>
<p class="card-text mb-0">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
<div class="card-footer p-4 pt-0 bg-transparent border-top-0">
<div class="d-flex align-items-end justify-content-between">
<div class="d-flex align-items-center">
<img class="rounded-circle me-3" src="https://dummyimage.com/40x40/ced4da/6c757d" alt="..." />
<div class="small">
<div class="fw-bold">Kelly Rowan</div>
<div class="text-muted">March 12, 2022 · 6 min read</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 mb-5">
<div class="card h-100 shadow border-0">
<img class="card-img-top" src="https://dummyimage.com/600x350/adb5bd/495057" alt="..." />
<div class="card-body p-4">
<div class="badge bg-primary bg-gradient rounded-pill mb-2">Media</div>
<a class="text-decoration-none link-dark stretched-link" href="#!"><h5 class="card-title mb-3">Another blog post title</h5></a>
<p class="card-text mb-0">This text is a bit longer to illustrate the adaptive height of each card. Some quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
<div class="card-footer p-4 pt-0 bg-transparent border-top-0">
<div class="d-flex align-items-end justify-content-between">
<div class="d-flex align-items-center">
<img class="rounded-circle me-3" src="https://dummyimage.com/40x40/ced4da/6c757d" alt="..." />
<div class="small">
<div class="fw-bold">Josiah Barclay</div>
<div class="text-muted">March 23, 2022 · 4 min read</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 mb-5">
<div class="card h-100 shadow border-0">
<img class="card-img-top" src="https://dummyimage.com/600x350/6c757d/343a40" alt="..." />
<div class="card-body p-4">
<div class="badge bg-primary bg-gradient rounded-pill mb-2">News</div>
<a class="text-decoration-none link-dark stretched-link" href="#!"><h5 class="card-title mb-3">The last blog post title is a little bit longer than the others</h5></a>
<p class="card-text mb-0">Some more quick example text to build on the card title and make up the bulk of the card's content.</p>
</div>
<div class="card-footer p-4 pt-0 bg-transparent border-top-0">
<div class="d-flex align-items-end justify-content-between">
<div class="d-flex align-items-center">
<img class="rounded-circle me-3" src="https://dummyimage.com/40x40/ced4da/6c757d" alt="..." />
<div class="small">
<div class="fw-bold">Evelyn Martinez</div>
<div class="text-muted">April 2, 2022 · 10 min read</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Call to action-->
<aside class="bg-primary bg-gradient rounded-3 p-4 p-sm-5 mt-5">
<div class="d-flex align-items-center justify-content-between flex-column flex-xl-row text-center text-xl-start">
<div class="mb-4 mb-xl-0">
<div class="fs-3 fw-bold text-white">New products, delivered to you.</div>
<div class="text-white-50">Sign up for our newsletter for the latest updates.</div>
</div>
<div class="ms-xl-4">
<div class="input-group mb-2">
<input class="form-control" type="text" placeholder="Email address..." aria-label="Email address..." aria-describedby="button-newsletter" />
<button class="btn btn-outline-light" id="button-newsletter" type="button">Sign up</button>
</div>
<div class="small text-white-50">We care about privacy, and will never share your data.</div>
</div>
</div>
</aside>
</div>
</section>
</main>
<!-- Footer-->
<footer class="bg-dark py-4 mt-auto">
<div class="container px-5">
<div class="row align-items-center justify-content-between flex-column flex-sm-row">
<div class="col-auto"><div class="small m-0 text-white">Copyright © Your Website 2022</div></div>
<div class="col-auto">
<a class="link-light small" href="#!">Privacy</a>
<span class="text-white mx-1">·</span>
<a class="link-light small" href="#!">Terms</a>
<span class="text-white mx-1">·</span>
<a class="link-light small" href="#!">Contact</a>
</div>
</div>
</div>
</footer>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>