Showing
2 changed files
with
8 additions
and
34 deletions
... | @@ -2,23 +2,13 @@ var express = require('express'); | ... | @@ -2,23 +2,13 @@ var express = require('express'); |
2 | var bodyParser = require('body-parser'); | 2 | var bodyParser = require('body-parser'); |
3 | var request = require('request'); | 3 | var request = require('request'); |
4 | var cheerio = require('cheerio'); | 4 | var cheerio = require('cheerio'); |
5 | - | ||
6 | var app =express(); | 5 | var app =express(); |
7 | -const HTTPS = require('https'); | ||
8 | -const domain = "www.stagefive.tk" | ||
9 | -const sslport = 80; | ||
10 | 6 | ||
11 | app.set('view engine','ejs'); | 7 | app.set('view engine','ejs'); |
12 | app.set('views','./views') | 8 | app.set('views','./views') |
13 | app.use(express.urlencoded( {extended : false } )); | 9 | app.use(express.urlencoded( {extended : false } )); |
14 | app.locals.pretty=true; | 10 | app.locals.pretty=true; |
15 | 11 | ||
16 | -// app.set('view engine','pug'); | ||
17 | - | ||
18 | -app.use(express.static('public')); | ||
19 | -var http = require('http'); | ||
20 | -var fs = require('fs'); | ||
21 | - | ||
22 | //?page=페이지번호&?perPage=페이지당 데이터수 | 12 | //?page=페이지번호&?perPage=페이지당 데이터수 |
23 | const $base_url = `https://api.odcloud.kr/api/apnmOrg/v1/list`; | 13 | const $base_url = `https://api.odcloud.kr/api/apnmOrg/v1/list`; |
24 | const $key = '4US0H%2BXj%2BmS8IR4YL0%2BUb9H4CcbTr92QxhYULfOEz1DT%2BZaaos4sRfNh6cmAD2Icli862Ysc31%2BaE4pWywDBIA%3D%3D'; | 14 | const $key = '4US0H%2BXj%2BmS8IR4YL0%2BUb9H4CcbTr92QxhYULfOEz1DT%2BZaaos4sRfNh6cmAD2Icli862Ysc31%2BaE4pWywDBIA%3D%3D'; |
... | @@ -34,18 +24,14 @@ app.post('/',function(req,res,next){ | ... | @@ -34,18 +24,14 @@ app.post('/',function(req,res,next){ |
34 | 24 | ||
35 | request($api_url,function(err,response,body){ | 25 | request($api_url,function(err,response,body){ |
36 | if(err) throw err; | 26 | if(err) throw err; |
37 | - // console.log(body); | ||
38 | //data부분만 추출 | 27 | //data부분만 추출 |
39 | var obj = JSON.parse(body).data; | 28 | var obj = JSON.parse(body).data; |
40 | - // console.log(obj); | ||
41 | //검색한 지역 포함한 모든 data 담기 | 29 | //검색한 지역 포함한 모든 data 담기 |
42 | let searchList = obj.filter(searchList => { | 30 | let searchList = obj.filter(searchList => { |
43 | return searchList.orgZipaddr.includes(searchWord); | 31 | return searchList.orgZipaddr.includes(searchWord); |
44 | }); | 32 | }); |
45 | 33 | ||
46 | - // console.log(searchList); | ||
47 | //result라는 변수에 담아 결과 보내기 | 34 | //result라는 변수에 담아 결과 보내기 |
48 | - // var hey = searchList[0].orgZipaddr.split(','); | ||
49 | var timeList=[]; | 35 | var timeList=[]; |
50 | for(var i=0; i<searchList.length; i++){ //시간정보 파싱 | 36 | for(var i=0; i<searchList.length; i++){ //시간정보 파싱 |
51 | var eachtime=[]; | 37 | var eachtime=[]; |
... | @@ -87,9 +73,7 @@ app.post('/',function(req,res,next){ | ... | @@ -87,9 +73,7 @@ app.post('/',function(req,res,next){ |
87 | 73 | ||
88 | } | 74 | } |
89 | res.render('index', {result:JSON.stringify(searchList),info:searchList ,timeList:timeList}); | 75 | res.render('index', {result:JSON.stringify(searchList),info:searchList ,timeList:timeList}); |
90 | - | ||
91 | }) | 76 | }) |
92 | - | ||
93 | }) | 77 | }) |
94 | 78 | ||
95 | app.get('/',function(req,res){ | 79 | app.get('/',function(req,res){ | ... | ... |
... | @@ -3,7 +3,6 @@ | ... | @@ -3,7 +3,6 @@ |
3 | <head> | 3 | <head> |
4 | <meta charset="utf-8"> | 4 | <meta charset="utf-8"> |
5 | <title>코로나 백신 의료기관 조회</title> | 5 | <title>코로나 백신 의료기관 조회</title> |
6 | - | ||
7 | <%if(typeof(info)!="undefined"){%> | 6 | <%if(typeof(info)!="undefined"){%> |
8 | <script> | 7 | <script> |
9 | try { | 8 | try { |
... | @@ -18,10 +17,8 @@ | ... | @@ -18,10 +17,8 @@ |
18 | </head> | 17 | </head> |
19 | <body> | 18 | <body> |
20 | <center> | 19 | <center> |
20 | + <h1 style="font-family:verdana;">COVID-19 예방접종 위탁 의료기관 조회</h1> <hr> | ||
21 | 21 | ||
22 | - <!-- <div style="background: #e8ecff; border-left: 0.5em solid #688FF4;border-right: 0.5em solid #688FF4; padding: 0.5em;"> --> | ||
23 | - <h2>COVID-19 예방접종 위탁 의료기관 조회</h2> <hr> | ||
24 | - <!-- </div> --> | ||
25 | <form action="/" method="post"> | 22 | <form action="/" method="post"> |
26 | <p> | 23 | <p> |
27 | <div style="float:right; width:40%; margin-bottom:10px; margin-right: 5px;"> | 24 | <div style="float:right; width:40%; margin-bottom:10px; margin-right: 5px;"> |
... | @@ -31,12 +28,10 @@ | ... | @@ -31,12 +28,10 @@ |
31 | </p> | 28 | </p> |
32 | </form> | 29 | </form> |
33 | </center> | 30 | </center> |
34 | - | 31 | + |
35 | - <div id="map" style="width:1300px;height:750px; margin-left:100px; float:left; border: 3px solid; " ></div> | ||
36 | <script type="text/javascript" src="https://dapi.kakao.com/v2/maps/sdk.js?appkey=35fccf4b4e2a3179187346f26ed3f988&libraries=services"></script> | 32 | <script type="text/javascript" src="https://dapi.kakao.com/v2/maps/sdk.js?appkey=35fccf4b4e2a3179187346f26ed3f988&libraries=services"></script> |
37 | - | ||
38 | <% if(typeof(info) != "undefined"){ %> | 33 | <% if(typeof(info) != "undefined"){ %> |
39 | - | 34 | + <div id="map" style="width:65%;height:550px;float:left; margin-left: 2%; border-radius: 2%; border:1px solid black" ></div> |
40 | <div style="overflow:scroll; width:25%; height:550px;float:left; margin-left:2%; border:1px solid black;"> | 35 | <div style="overflow:scroll; width:25%; height:550px;float:left; margin-left:2%; border:1px solid black;"> |
41 | <ol id="placelist"> | 36 | <ol id="placelist"> |
42 | <% for(i=0; i<info.length; i++){%> | 37 | <% for(i=0; i<info.length; i++){%> |
... | @@ -48,7 +43,6 @@ | ... | @@ -48,7 +43,6 @@ |
48 | <%}else { %> | 43 | <%}else { %> |
49 | <span style="color:green"> (정상운영) </span> | 44 | <span style="color:green"> (정상운영) </span> |
50 | <%}%> | 45 | <%}%> |
51 | - | ||
52 | <br> | 46 | <br> |
53 | <% if(timeList[i][0]!="" && timeList[i][1]!="" && timeList[i][2]!="" && timeList[i][3]!=""){%> | 47 | <% if(timeList[i][0]!="" && timeList[i][1]!="" && timeList[i][2]!="" && timeList[i][3]!=""){%> |
54 | <span>점심시간 : <%=timeList[i][0]%>:<%=timeList[i][1]%>~<%=timeList[i][2]%>:<%=timeList[i][3] %></span><br> | 48 | <span>점심시간 : <%=timeList[i][0]%>:<%=timeList[i][1]%>~<%=timeList[i][2]%>:<%=timeList[i][3] %></span><br> |
... | @@ -64,10 +58,7 @@ | ... | @@ -64,10 +58,7 @@ |
64 | <%} %> | 58 | <%} %> |
65 | </ol> | 59 | </ol> |
66 | </div> | 60 | </div> |
67 | - <%}else{%> | 61 | + <%}%> |
68 | - <div style="overflow:scroll; width:25%; height:550px;float:left; margin-left:2%; border:1px solid black;"> | ||
69 | - </div> | ||
70 | - <% } %> | ||
71 | 62 | ||
72 | <% if(typeof(result) != "undefined"){ %> | 63 | <% if(typeof(result) != "undefined"){ %> |
73 | <script> | 64 | <script> |
... | @@ -88,7 +79,6 @@ | ... | @@ -88,7 +79,6 @@ |
88 | listData = JSON.parse(listData); | 79 | listData = JSON.parse(listData); |
89 | 80 | ||
90 | var count = 0; | 81 | var count = 0; |
91 | - | ||
92 | //입력되는 배열명이 listData로 들어오면 됨. | 82 | //입력되는 배열명이 listData로 들어오면 됨. |
93 | listData.forEach(function(addr, index) { | 83 | listData.forEach(function(addr, index) { |
94 | var tmpaddr = ((addr.orgZipaddr).split(','))[0]; | 84 | var tmpaddr = ((addr.orgZipaddr).split(','))[0]; |
... | @@ -98,7 +88,6 @@ | ... | @@ -98,7 +88,6 @@ |
98 | var coords = new kakao.maps.LatLng(result[0].y, result[0].x); | 88 | var coords = new kakao.maps.LatLng(result[0].y, result[0].x); |
99 | 89 | ||
100 | count += 1; | 90 | count += 1; |
101 | - | ||
102 | var marker = new kakao.maps.Marker({ | 91 | var marker = new kakao.maps.Marker({ |
103 | position: coords, | 92 | position: coords, |
104 | clickable: true | 93 | clickable: true |
... | @@ -135,7 +124,6 @@ | ... | @@ -135,7 +124,6 @@ |
135 | infowindow.close(); | 124 | infowindow.close(); |
136 | }; | 125 | }; |
137 | } | 126 | } |
138 | - | ||
139 | var infowindows = []; | 127 | var infowindows = []; |
140 | function displayinfowindow(address,name,flag){ | 128 | function displayinfowindow(address,name,flag){ |
141 | if(flag){ | 129 | if(flag){ |
... | @@ -143,7 +131,7 @@ | ... | @@ -143,7 +131,7 @@ |
143 | geocoder.addressSearch(tmpaddr, function(result, status) { | 131 | geocoder.addressSearch(tmpaddr, function(result, status) { |
144 | if (status === kakao.maps.services.Status.OK) { | 132 | if (status === kakao.maps.services.Status.OK) { |
145 | var coords = new kakao.maps.LatLng(result[0].y, result[0].x); | 133 | var coords = new kakao.maps.LatLng(result[0].y, result[0].x); |
146 | - //map.setCenter(coords);//인포윈도우 생성 마커로 이동 | 134 | + map.setCenter(coords);//인포윈도우 생성 마커로 이동 |
147 | var marker = new kakao.maps.Marker({ | 135 | var marker = new kakao.maps.Marker({ |
148 | position: coords, | 136 | position: coords, |
149 | clickable: true | 137 | clickable: true |
... | @@ -164,15 +152,17 @@ | ... | @@ -164,15 +152,17 @@ |
164 | } | 152 | } |
165 | </script> | 153 | </script> |
166 | <% }else{ %> | 154 | <% }else{ %> |
155 | + <div id="map" style="width:90%;height:550px;float:left; margin-left: 2%; border-radius: 2%; border:1px solid black" ></div> | ||
167 | <script>//입력 값이 없을 때 기본 지도 띄움 | 156 | <script>//입력 값이 없을 때 기본 지도 띄움 |
168 | var mapContainer = document.getElementById('map'), // 지도를 표시할 div | 157 | var mapContainer = document.getElementById('map'), // 지도를 표시할 div |
169 | mapOption = { | 158 | mapOption = { |
170 | center: new kakao.maps.LatLng(37.596672, 127.051950), // 지도의 중심좌표 | 159 | center: new kakao.maps.LatLng(37.596672, 127.051950), // 지도의 중심좌표 |
171 | level: 3 // 지도의 확대 레벨 | 160 | level: 3 // 지도의 확대 레벨 |
172 | }; | 161 | }; |
173 | - | 162 | + |
174 | var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다 | 163 | var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다 |
175 | </script> | 164 | </script> |
165 | + | ||
176 | <% } %> | 166 | <% } %> |
177 | </body> | 167 | </body> |
178 | </html> | 168 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment