송효섭

sql 적용 카카오맵 마킹 테스트

...@@ -5,6 +5,7 @@ const app = express(); ...@@ -5,6 +5,7 @@ const app = express();
5 //화면 별 router 연결, 라우터 호출해서 페이지를 불러오는데 사용함. 5 //화면 별 router 연결, 라우터 호출해서 페이지를 불러오는데 사용함.
6 var mainRouter = require('./routes') //호출시 main.js 실행 (main.js : title 할당하고 main.html 열어줌) 6 var mainRouter = require('./routes') //호출시 main.js 실행 (main.js : title 할당하고 main.html 열어줌)
7 var loginRouter = require('./routes/login') 7 var loginRouter = require('./routes/login')
8 +var NearContentRouter = require('./routes/database')
8 //디폴트 포트 값 : 8000 9 //디폴트 포트 값 : 8000
9 app.set('port', process.env.PORT || 8000); 10 app.set('port', process.env.PORT || 8000);
10 11
...@@ -16,15 +17,15 @@ app.engine('html', require('ejs').renderFile); ...@@ -16,15 +17,15 @@ app.engine('html', require('ejs').renderFile);
16 //각각의 요청에서 router 호출해서 page를 전환함. 17 //각각의 요청에서 router 호출해서 page를 전환함.
17 app.use('/', mainRouter); 18 app.use('/', mainRouter);
18 app.use('/login', loginRouter); 19 app.use('/login', loginRouter);
19 - 20 +// app.use('/map', NearContentRouter);
20 21
21 //css, image 등 정적 파일을 public에서 불러옴 -> html과 연결함 22 //css, image 등 정적 파일을 public에서 불러옴 -> html과 연결함
22 app.use(express.static(path.join(__dirname, 'public'))); 23 app.use(express.static(path.join(__dirname, 'public')));
23 24
24 25
25 -app.get('/logout', function (req, res) { 26 +// app.get('/logout', function (req, res) {
26 - res.send("Logout success"); 27 +// res.send("Logout success");
27 -}); 28 +// });
28 29
29 30
30 app.listen(app.get('port'), () => { 31 app.listen(app.get('port'), () => {
......
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 +
3 <head> 4 <head>
4 <meta charset="utf-8"> 5 <meta charset="utf-8">
5 <title>geolocation으로 마커 표시하기</title> 6 <title>geolocation으로 마커 표시하기</title>
6 - 7 +
7 </head> 8 </head>
9 +
8 <body> 10 <body>
9 -<p style="margin-top:-12px"> 11 + <p style="margin-top:-12px">
10 - <b>Chrome 브라우저는 https 환경에서만 geolocation을 지원합니다.</b> 참고해주세요. 12 + <b>Chrome 브라우저는 https 환경에서만 geolocation을 지원합니다.</b> 참고해주세요.
11 -</p> 13 + </p>
12 -<div id="map" style="width:500px;height:350px;"></div> 14 + <div id="map" style="width:500px;height:350px;"></div>
13 - 15 +
14 -<script type="text/javascript" src="//dapi.kakao.com/v2/maps/sdk.js?appkey=a3386042ab2e0550ea06d265855b452c">//kakao map api 주소 받아옴</script> 16 + <script type="text/javascript"
15 -<script> 17 + src="//dapi.kakao.com/v2/maps/sdk.js?appkey=a3386042ab2e0550ea06d265855b452c">//kakao map api 주소 받아옴</script>
16 -const near=require('study.js'); 18 + <script>
17 - 19 + const near = require('study.js');
18 -var mapContainer = document.getElementById('map'), // 지도를 표시할 div 20 +
19 - mapOption = { 21 + var mapContainer = document.getElementById('map'), // 지도를 표시할 div
20 - center: new kakao.maps.LatLng(33.450701, 126.570667), // 지도의 중심좌표 22 + mapOption = {
21 - level: 10 // 지도의 확대 레벨 23 + center: new kakao.maps.LatLng(33.450701, 126.570667), // 지도의 중심좌표
22 - }; 24 + level: 10 // 지도의 확대 레벨
23 - 25 + };
24 -var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다 26 +
25 - 27 + var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다
26 -// HTML5의 geolocation으로 사용할 수 있는지 확인합니다 28 +
27 -if (navigator.geolocation) { 29 + // HTML5의 geolocation으로 사용할 수 있는지 확인합니다
28 - 30 + if (navigator.geolocation) {
29 - // GeoLocation을 이용해서 접속 위치를 얻어옵니다 31 +
30 - navigator.geolocation.getCurrentPosition(function(position) { 32 + // GeoLocation을 이용해서 접속 위치를 얻어옵니다
31 - 33 + navigator.geolocation.getCurrentPosition(function (position) {
32 - var lat = position.coords.latitude, // 위도 34 +
33 - lon = position.coords.longitude; // 경도 35 + var lat = position.coords.latitude, // 위도
34 - console.log(lat); 36 + lon = position.coords.longitude; // 경도
35 - console.log(lon); 37 + console.log(lat);
36 - var locPosition = new kakao.maps.LatLng(lat, lon), // 마커가 표시될 위치를 geolocation으로 얻어온 좌표로 생성합니다 38 + console.log(lon);
37 - message = '<div style="padding:5px;">여기에 계신가요?!</div>'; // 인포윈도우에 표시될 내용입니다 39 + var locPosition = new kakao.maps.LatLng(lat, lon), // 마커가 표시될 위치를 geolocation으로 얻어온 좌표로 생성합니다
38 - 40 + message = '<div style="padding:5px;">여기에 계신가요?!</div>'; // 인포윈도우에 표시될 내용입니다
39 - // 마커와 인포윈도우를 표시합니다 41 +
40 - displayMarker(locPosition, message); 42 + // 마커와 인포윈도우를 표시합니다
41 - 43 + displayMarker(locPosition, message);
42 - }); 44 + });
43 - 45 +
44 -} else { // HTML5의 GeoLocation을 사용할 수 없을때 마커 표시 위치와 인포윈도우 내용을 설정합니다 46 + } else { // HTML5의 GeoLocation을 사용할 수 없을때 마커 표시 위치와 인포윈도우 내용을 설정합니다
45 - 47 +
46 - var locPosition = new kakao.maps.LatLng(33.450701, 126.570667), 48 + var locPosition = new kakao.maps.LatLng(33.450701, 126.570667),
47 - message = 'geolocation을 사용할수 없어요..' 49 + message = 'geolocation을 사용할수 없어요..'
48 - 50 +
49 - displayMarker(locPosition, message); 51 + displayMarker(locPosition, message);
50 -} 52 + }
51 - 53 +
52 - 54 +
53 - 55 +
54 - 56 +
55 -displayShows(); 57 + displayShows();
56 -function displayShows(){ 58 + function displayShows() {
57 - var imageSrc = "https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/markerStar.png"; 59 + var imageSrc = "https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/markerStar.png";
58 - var near_list=near(lat,lon); 60 + var near_list = near(lat, lon);
59 - var positions=[]; 61 + var positions = [];
60 - for(var i =0;i<near_list.length;i++){ 62 + for (var i = 0; i < near_list.length; i++) {
61 - positions.push({title: id, 63 + positions.push({
62 - lating: new kaka0.maps.Lating(near_list[i][1],near_list[i][2])}) 64 + title: id,
63 - } 65 + lating: new kakao.maps.Lating(near_list[i][1], near_list[i][2])
64 -for (var i = 0; i < positions.length; i ++) { 66 + })
65 - 67 + }
66 - // 마커 이미지의 이미지 크기 입니다 68 + for (var i = 0; i < positions.length; i++) {
67 - var imageSize = new kakao.maps.Size(24, 35); 69 +
68 - 70 + // 마커 이미지의 이미지 크기 입니다
69 - // 마커 이미지를 생성합니다 71 + var imageSize = new kakao.maps.Size(24, 35);
70 - var markerImage = new kakao.maps.MarkerImage(imageSrc, imageSize); 72 +
71 - 73 + // 마커 이미지를 생성합니다
72 - // 마커를 생성합니다 74 + var markerImage = new kakao.maps.MarkerImage(imageSrc, imageSize);
73 - var marker = new kakao.maps.Marker({ 75 +
74 - map: map, // 마커를 표시할 지도 76 + // 마커를 생성합니다
75 - position: positions[i].latlng, // 마커를 표시할 위치 77 + var marker = new kakao.maps.Marker({
76 - title : positions[i].title, // 마커의 타이틀, 마커에 마우스를 올리면 타이틀이 표시됩니다 78 + map: map, // 마커를 표시할 지도
77 - image : markerImage // 마커 이미지 79 + position: positions[i].latlng, // 마커를 표시할 위치
78 - }); 80 + title: positions[i].title, // 마커의 타이틀, 마커에 마우스를 올리면 타이틀이 표시됩니다
79 - } 81 + image: markerImage // 마커 이미지
80 -} 82 + });
81 -// 지도에 마커와 인포윈도우를 표시하는 함수입니다 83 + }
82 -function displayMarker(locPosition, message) { 84 + }
83 - 85 + // 지도에 마커와 인포윈도우를 표시하는 함수입니다
84 - // 마커를 생성합니다 86 + function displayMarker(locPosition, message) {
85 - var marker = new kakao.maps.Marker({ 87 +
86 - map: map, 88 + // 마커를 생성합니다
87 - position: locPosition 89 + var marker = new kakao.maps.Marker({
88 - }); 90 + map: map,
89 - 91 + position: locPosition
90 - var iwContent = message, // 인포윈도우에 표시할 내용 92 + });
91 - iwRemoveable = true; 93 +
92 - 94 + var iwContent = message, // 인포윈도우에 표시할 내용
93 - // 인포윈도우를 생성합니다 95 + iwRemoveable = true;
94 - var infowindow = new kakao.maps.InfoWindow({ 96 +
95 - content : iwContent, 97 + // 인포윈도우를 생성합니다
96 - removable : iwRemoveable 98 + var infowindow = new kakao.maps.InfoWindow({
97 - }); 99 + content: iwContent,
98 - 100 + removable: iwRemoveable
99 - // 인포윈도우를 마커위에 표시합니다 101 + });
100 - infowindow.open(map, marker); 102 +
101 - 103 + // 인포윈도우를 마커위에 표시합니다
102 - // 지도 중심좌표를 접속위치로 변경합니다 104 + infowindow.open(map, marker);
103 - map.setCenter(locPosition); 105 +
104 -} 106 + // 지도 중심좌표를 접속위치로 변경합니다
105 -</script> 107 + map.setCenter(locPosition);
108 + }
109 + </script>
106 </body> 110 </body>
111 +
107 </html> 112 </html>
...\ No newline at end of file ...\ No newline at end of file
......
1 var mysql = require('mysql'); 1 var mysql = require('mysql');
2 2
3 -module.exports={ 3 +module.exports = {
4 - nearShow: function(lat,lon){ 4 + nearShow: function (lat, lon) {
5 - var near_show_list=[]; 5 + var near_show_list = [];
6 - var connection = mysql.createConnection({ 6 + var connection = mysql.createConnection({
7 - "host": "culturegallery.cm2bwcuyukrm.us-east-1.rds.amazonaws.com", 7 + "host": "culturegallery.cm2bwcuyukrm.us-east-1.rds.amazonaws.com",
8 - "user":"root", 8 + "user": "root",
9 - "password": "dldbwp1207", 9 + "password": "dldbwp1207",
10 - "port": "3306", 10 + "port": "3306",
11 - "database": "showdata" 11 + "database": "showdata"
12 - }); 12 + });
13 -
14 - connection.connect();
15 - var dataNum=0;
16 - connection.query('SELECT COUNT (*) AS cnt FROM SHOW_DATA',function(error,results,field){
17 - if(error){
18 - console.log(error);
19 - }
20 - console.log(results[0].cnt);
21 - dataNum=results[0].cnt;
22 - });
23 13
24 - connection.query('SELECT id,latitude,longitude FROM SHOW_DATA',function(error,results,field){ 14 + connection.connect();
25 - if(error){ 15 + var dataNum = 0;
26 - console.log(error); 16 + connection.query('SELECT COUNT (*) AS cnt FROM SHOW_DATA', function (error, results, field) {
27 - } 17 + if (error) {
28 - console.log([lat,lon]); 18 + console.log(error);
29 - for(var i=0;i<dataNum;i++){
30 - var latgap=(lat-results[i].latitude)*110;
31 - var longap=(lon-results[i].longitude)*91;
32 - var cal=latgap*latgap+longap*longap;
33 - if(cal<=1600){
34 - console.log(results[i].id);
35 - near_show_list.push([results[i].id,results[i].latitude,results[i].longitude]);
36 } 19 }
37 - } 20 + console.log(results[0].cnt);
38 - }); 21 + dataNum = results[0].cnt;
39 - 22 + });
40 - connection.end(); 23 +
41 - return near_show_list; 24 + connection.query('SELECT id,latitude,longitude FROM SHOW_DATA', function (error, results, field) {
25 + if (error) {
26 + console.log(error);
27 + }
28 + console.log([lat, lon]);
29 + for (var i = 0; i < dataNum; i++) {
30 + var latgap = (lat - results[i].latitude) * 110;
31 + var longap = (lon - results[i].longitude) * 91;
32 + var cal = latgap * latgap + longap * longap;
33 +
34 + //내 위치 반경 키로수 ^ 2만큼 cal 값 push -> content 위치
35 + if (cal <= 1600) {
36 + console.log(results[i].id);
37 + near_show_list.push([results[i].id, results[i].latitude, results[i].longitude]);
38 + }
39 + }
40 + });
41 +
42 + connection.end();
43 + return near_show_list;
42 } 44 }
43 } 45 }
......
1 { 1 {
2 "name": "culturegallery", 2 "name": "culturegallery",
3 "version": "1.0.0", 3 "version": "1.0.0",
4 - "lockfileVersion": 1, 4 + "lockfileVersion": 2,
5 "requires": true, 5 "requires": true,
6 + "packages": {
7 + "": {
8 + "name": "culturegallery",
9 + "version": "1.0.0",
10 + "license": "MIT",
11 + "dependencies": {
12 + "ejs": "^3.1.5",
13 + "express": "^4.17.1",
14 + "mysql": "^2.18.1"
15 + }
16 + },
17 + "node_modules/accepts": {
18 + "version": "1.3.7",
19 + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
20 + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
21 + "dependencies": {
22 + "mime-types": "~2.1.24",
23 + "negotiator": "0.6.2"
24 + }
25 + },
26 + "node_modules/ansi-styles": {
27 + "version": "3.2.1",
28 + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
29 + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
30 + "dependencies": {
31 + "color-convert": "^1.9.0"
32 + }
33 + },
34 + "node_modules/array-flatten": {
35 + "version": "1.1.1",
36 + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
37 + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI="
38 + },
39 + "node_modules/async": {
40 + "version": "0.9.2",
41 + "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz",
42 + "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0="
43 + },
44 + "node_modules/balanced-match": {
45 + "version": "1.0.0",
46 + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
47 + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
48 + },
49 + "node_modules/bignumber.js": {
50 + "version": "9.0.0",
51 + "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz",
52 + "integrity": "sha512-t/OYhhJ2SD+YGBQcjY8GzzDHEk9f3nerxjtfa6tlMXfe7frs/WozhvCNoGvpM0P3bNf3Gq5ZRMlGr5f3r4/N8A==",
53 + "engines": {
54 + "node": "*"
55 + }
56 + },
57 + "node_modules/body-parser": {
58 + "version": "1.19.0",
59 + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz",
60 + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==",
61 + "dependencies": {
62 + "bytes": "3.1.0",
63 + "content-type": "~1.0.4",
64 + "debug": "2.6.9",
65 + "depd": "~1.1.2",
66 + "http-errors": "1.7.2",
67 + "iconv-lite": "0.4.24",
68 + "on-finished": "~2.3.0",
69 + "qs": "6.7.0",
70 + "raw-body": "2.4.0",
71 + "type-is": "~1.6.17"
72 + }
73 + },
74 + "node_modules/brace-expansion": {
75 + "version": "1.1.11",
76 + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
77 + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
78 + "dependencies": {
79 + "balanced-match": "^1.0.0",
80 + "concat-map": "0.0.1"
81 + }
82 + },
83 + "node_modules/bytes": {
84 + "version": "3.1.0",
85 + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
86 + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg=="
87 + },
88 + "node_modules/chalk": {
89 + "version": "2.4.2",
90 + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
91 + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
92 + "dependencies": {
93 + "ansi-styles": "^3.2.1",
94 + "escape-string-regexp": "^1.0.5",
95 + "supports-color": "^5.3.0"
96 + }
97 + },
98 + "node_modules/color-convert": {
99 + "version": "1.9.3",
100 + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
101 + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
102 + "dependencies": {
103 + "color-name": "1.1.3"
104 + }
105 + },
106 + "node_modules/color-name": {
107 + "version": "1.1.3",
108 + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
109 + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
110 + },
111 + "node_modules/concat-map": {
112 + "version": "0.0.1",
113 + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
114 + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
115 + },
116 + "node_modules/content-disposition": {
117 + "version": "0.5.3",
118 + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz",
119 + "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==",
120 + "dependencies": {
121 + "safe-buffer": "5.1.2"
122 + }
123 + },
124 + "node_modules/content-type": {
125 + "version": "1.0.4",
126 + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
127 + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA=="
128 + },
129 + "node_modules/cookie": {
130 + "version": "0.4.0",
131 + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz",
132 + "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg=="
133 + },
134 + "node_modules/cookie-signature": {
135 + "version": "1.0.6",
136 + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
137 + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw="
138 + },
139 + "node_modules/core-util-is": {
140 + "version": "1.0.2",
141 + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
142 + "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
143 + },
144 + "node_modules/debug": {
145 + "version": "2.6.9",
146 + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
147 + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
148 + "dependencies": {
149 + "ms": "2.0.0"
150 + }
151 + },
152 + "node_modules/depd": {
153 + "version": "1.1.2",
154 + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz",
155 + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
156 + },
157 + "node_modules/destroy": {
158 + "version": "1.0.4",
159 + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz",
160 + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA="
161 + },
162 + "node_modules/ee-first": {
163 + "version": "1.1.1",
164 + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
165 + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0="
166 + },
167 + "node_modules/ejs": {
168 + "version": "3.1.5",
169 + "resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.5.tgz",
170 + "integrity": "sha512-dldq3ZfFtgVTJMLjOe+/3sROTzALlL9E34V4/sDtUd/KlBSS0s6U1/+WPE1B4sj9CXHJpL1M6rhNJnc9Wbal9w==",
171 + "dependencies": {
172 + "jake": "^10.6.1"
173 + }
174 + },
175 + "node_modules/encodeurl": {
176 + "version": "1.0.2",
177 + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
178 + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k="
179 + },
180 + "node_modules/escape-html": {
181 + "version": "1.0.3",
182 + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
183 + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg="
184 + },
185 + "node_modules/escape-string-regexp": {
186 + "version": "1.0.5",
187 + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
188 + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
189 + },
190 + "node_modules/etag": {
191 + "version": "1.8.1",
192 + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
193 + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
194 + },
195 + "node_modules/express": {
196 + "version": "4.17.1",
197 + "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz",
198 + "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==",
199 + "dependencies": {
200 + "accepts": "~1.3.7",
201 + "array-flatten": "1.1.1",
202 + "body-parser": "1.19.0",
203 + "content-disposition": "0.5.3",
204 + "content-type": "~1.0.4",
205 + "cookie": "0.4.0",
206 + "cookie-signature": "1.0.6",
207 + "debug": "2.6.9",
208 + "depd": "~1.1.2",
209 + "encodeurl": "~1.0.2",
210 + "escape-html": "~1.0.3",
211 + "etag": "~1.8.1",
212 + "finalhandler": "~1.1.2",
213 + "fresh": "0.5.2",
214 + "merge-descriptors": "1.0.1",
215 + "methods": "~1.1.2",
216 + "on-finished": "~2.3.0",
217 + "parseurl": "~1.3.3",
218 + "path-to-regexp": "0.1.7",
219 + "proxy-addr": "~2.0.5",
220 + "qs": "6.7.0",
221 + "range-parser": "~1.2.1",
222 + "safe-buffer": "5.1.2",
223 + "send": "0.17.1",
224 + "serve-static": "1.14.1",
225 + "setprototypeof": "1.1.1",
226 + "statuses": "~1.5.0",
227 + "type-is": "~1.6.18",
228 + "utils-merge": "1.0.1",
229 + "vary": "~1.1.2"
230 + }
231 + },
232 + "node_modules/filelist": {
233 + "version": "1.0.1",
234 + "resolved": "https://registry.npmjs.org/filelist/-/filelist-1.0.1.tgz",
235 + "integrity": "sha512-8zSK6Nu0DQIC08mUC46sWGXi+q3GGpKydAG36k+JDba6VRpkevvOWUW5a/PhShij4+vHT9M+ghgG7eM+a9JDUQ==",
236 + "dependencies": {
237 + "minimatch": "^3.0.4"
238 + }
239 + },
240 + "node_modules/finalhandler": {
241 + "version": "1.1.2",
242 + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz",
243 + "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==",
244 + "dependencies": {
245 + "debug": "2.6.9",
246 + "encodeurl": "~1.0.2",
247 + "escape-html": "~1.0.3",
248 + "on-finished": "~2.3.0",
249 + "parseurl": "~1.3.3",
250 + "statuses": "~1.5.0",
251 + "unpipe": "~1.0.0"
252 + }
253 + },
254 + "node_modules/forwarded": {
255 + "version": "0.1.2",
256 + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
257 + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ="
258 + },
259 + "node_modules/fresh": {
260 + "version": "0.5.2",
261 + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
262 + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
263 + },
264 + "node_modules/has-flag": {
265 + "version": "3.0.0",
266 + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
267 + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
268 + },
269 + "node_modules/http-errors": {
270 + "version": "1.7.2",
271 + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz",
272 + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==",
273 + "dependencies": {
274 + "depd": "~1.1.2",
275 + "inherits": "2.0.3",
276 + "setprototypeof": "1.1.1",
277 + "statuses": ">= 1.5.0 < 2",
278 + "toidentifier": "1.0.0"
279 + }
280 + },
281 + "node_modules/iconv-lite": {
282 + "version": "0.4.24",
283 + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
284 + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
285 + "dependencies": {
286 + "safer-buffer": ">= 2.1.2 < 3"
287 + }
288 + },
289 + "node_modules/inherits": {
290 + "version": "2.0.3",
291 + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
292 + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
293 + },
294 + "node_modules/ipaddr.js": {
295 + "version": "1.9.1",
296 + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
297 + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g=="
298 + },
299 + "node_modules/isarray": {
300 + "version": "1.0.0",
301 + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
302 + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
303 + },
304 + "node_modules/jake": {
305 + "version": "10.8.2",
306 + "resolved": "https://registry.npmjs.org/jake/-/jake-10.8.2.tgz",
307 + "integrity": "sha512-eLpKyrfG3mzvGE2Du8VoPbeSkRry093+tyNjdYaBbJS9v17knImYGNXQCUV0gLxQtF82m3E8iRb/wdSQZLoq7A==",
308 + "dependencies": {
309 + "async": "0.9.x",
310 + "chalk": "^2.4.2",
311 + "filelist": "^1.0.1",
312 + "minimatch": "^3.0.4"
313 + }
314 + },
315 + "node_modules/media-typer": {
316 + "version": "0.3.0",
317 + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
318 + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g="
319 + },
320 + "node_modules/merge-descriptors": {
321 + "version": "1.0.1",
322 + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
323 + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E="
324 + },
325 + "node_modules/methods": {
326 + "version": "1.1.2",
327 + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
328 + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
329 + },
330 + "node_modules/mime": {
331 + "version": "1.6.0",
332 + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
333 + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg=="
334 + },
335 + "node_modules/mime-db": {
336 + "version": "1.44.0",
337 + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz",
338 + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
339 + },
340 + "node_modules/mime-types": {
341 + "version": "2.1.27",
342 + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz",
343 + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
344 + "dependencies": {
345 + "mime-db": "1.44.0"
346 + }
347 + },
348 + "node_modules/minimatch": {
349 + "version": "3.0.4",
350 + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
351 + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
352 + "dependencies": {
353 + "brace-expansion": "^1.1.7"
354 + }
355 + },
356 + "node_modules/ms": {
357 + "version": "2.0.0",
358 + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
359 + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
360 + },
361 + "node_modules/mysql": {
362 + "version": "2.18.1",
363 + "resolved": "https://registry.npmjs.org/mysql/-/mysql-2.18.1.tgz",
364 + "integrity": "sha512-Bca+gk2YWmqp2Uf6k5NFEurwY/0td0cpebAucFpY/3jhrwrVGuxU2uQFCHjU19SJfje0yQvi+rVWdq78hR5lig==",
365 + "dependencies": {
366 + "bignumber.js": "9.0.0",
367 + "readable-stream": "2.3.7",
368 + "safe-buffer": "5.1.2",
369 + "sqlstring": "2.3.1"
370 + },
371 + "engines": {
372 + "node": ">= 0.6"
373 + }
374 + },
375 + "node_modules/negotiator": {
376 + "version": "0.6.2",
377 + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
378 + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
379 + },
380 + "node_modules/on-finished": {
381 + "version": "2.3.0",
382 + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
383 + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=",
384 + "dependencies": {
385 + "ee-first": "1.1.1"
386 + }
387 + },
388 + "node_modules/parseurl": {
389 + "version": "1.3.3",
390 + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
391 + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
392 + },
393 + "node_modules/path-to-regexp": {
394 + "version": "0.1.7",
395 + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
396 + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w="
397 + },
398 + "node_modules/process-nextick-args": {
399 + "version": "2.0.1",
400 + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
401 + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
402 + },
403 + "node_modules/proxy-addr": {
404 + "version": "2.0.6",
405 + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.6.tgz",
406 + "integrity": "sha512-dh/frvCBVmSsDYzw6n926jv974gddhkFPfiN8hPOi30Wax25QZyZEGveluCgliBnqmuM+UJmBErbAUFIoDbjOw==",
407 + "dependencies": {
408 + "forwarded": "~0.1.2",
409 + "ipaddr.js": "1.9.1"
410 + }
411 + },
412 + "node_modules/qs": {
413 + "version": "6.7.0",
414 + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz",
415 + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ=="
416 + },
417 + "node_modules/range-parser": {
418 + "version": "1.2.1",
419 + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
420 + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg=="
421 + },
422 + "node_modules/raw-body": {
423 + "version": "2.4.0",
424 + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz",
425 + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==",
426 + "dependencies": {
427 + "bytes": "3.1.0",
428 + "http-errors": "1.7.2",
429 + "iconv-lite": "0.4.24",
430 + "unpipe": "1.0.0"
431 + }
432 + },
433 + "node_modules/readable-stream": {
434 + "version": "2.3.7",
435 + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.7.tgz",
436 + "integrity": "sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==",
437 + "dependencies": {
438 + "core-util-is": "~1.0.0",
439 + "inherits": "~2.0.3",
440 + "isarray": "~1.0.0",
441 + "process-nextick-args": "~2.0.0",
442 + "safe-buffer": "~5.1.1",
443 + "string_decoder": "~1.1.1",
444 + "util-deprecate": "~1.0.1"
445 + }
446 + },
447 + "node_modules/safe-buffer": {
448 + "version": "5.1.2",
449 + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
450 + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
451 + },
452 + "node_modules/safer-buffer": {
453 + "version": "2.1.2",
454 + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
455 + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
456 + },
457 + "node_modules/send": {
458 + "version": "0.17.1",
459 + "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz",
460 + "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==",
461 + "dependencies": {
462 + "debug": "2.6.9",
463 + "depd": "~1.1.2",
464 + "destroy": "~1.0.4",
465 + "encodeurl": "~1.0.2",
466 + "escape-html": "~1.0.3",
467 + "etag": "~1.8.1",
468 + "fresh": "0.5.2",
469 + "http-errors": "~1.7.2",
470 + "mime": "1.6.0",
471 + "ms": "2.1.1",
472 + "on-finished": "~2.3.0",
473 + "range-parser": "~1.2.1",
474 + "statuses": "~1.5.0"
475 + }
476 + },
477 + "node_modules/send/node_modules/ms": {
478 + "version": "2.1.1",
479 + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
480 + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
481 + },
482 + "node_modules/serve-static": {
483 + "version": "1.14.1",
484 + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz",
485 + "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==",
486 + "dependencies": {
487 + "encodeurl": "~1.0.2",
488 + "escape-html": "~1.0.3",
489 + "parseurl": "~1.3.3",
490 + "send": "0.17.1"
491 + }
492 + },
493 + "node_modules/setprototypeof": {
494 + "version": "1.1.1",
495 + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
496 + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
497 + },
498 + "node_modules/sqlstring": {
499 + "version": "2.3.1",
500 + "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz",
501 + "integrity": "sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=",
502 + "engines": {
503 + "node": ">= 0.6"
504 + }
505 + },
506 + "node_modules/statuses": {
507 + "version": "1.5.0",
508 + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz",
509 + "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow="
510 + },
511 + "node_modules/string_decoder": {
512 + "version": "1.1.1",
513 + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
514 + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
515 + "dependencies": {
516 + "safe-buffer": "~5.1.0"
517 + }
518 + },
519 + "node_modules/supports-color": {
520 + "version": "5.5.0",
521 + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
522 + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
523 + "dependencies": {
524 + "has-flag": "^3.0.0"
525 + }
526 + },
527 + "node_modules/toidentifier": {
528 + "version": "1.0.0",
529 + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
530 + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
531 + },
532 + "node_modules/type-is": {
533 + "version": "1.6.18",
534 + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
535 + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
536 + "dependencies": {
537 + "media-typer": "0.3.0",
538 + "mime-types": "~2.1.24"
539 + }
540 + },
541 + "node_modules/unpipe": {
542 + "version": "1.0.0",
543 + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
544 + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw="
545 + },
546 + "node_modules/util-deprecate": {
547 + "version": "1.0.2",
548 + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
549 + "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
550 + },
551 + "node_modules/utils-merge": {
552 + "version": "1.0.1",
553 + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
554 + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
555 + },
556 + "node_modules/vary": {
557 + "version": "1.1.2",
558 + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
559 + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw="
560 + }
561 + },
6 "dependencies": { 562 "dependencies": {
7 "accepts": { 563 "accepts": {
8 "version": "1.3.7", 564 "version": "1.3.7",
......
1 +var mysql = require('mysql');
2 +
3 +module.exports = {
4 + init: function (lat, lon) {
5 + var near_show_list = [];
6 + var connection = mysql.createConnection({
7 + "host": "culturegallery.cm2bwcuyukrm.us-east-1.rds.amazonaws.com",
8 + "user": "root",
9 + "password": "dldbwp1207",
10 + "port": "3306",
11 + "database": "showdata"
12 + });
13 +
14 + connection.connect();
15 + var dataNum = 0;
16 + connection.query('SELECT COUNT (*) AS cnt FROM SHOW_DATA', function (error, results, field) {
17 + if (error) {
18 + console.log(error);
19 + }
20 + console.log(results[0].cnt);
21 + dataNum = results[0].cnt;
22 + });
23 +
24 + connection.query('SELECT id,latitude,longitude FROM SHOW_DATA', function (error, results, field) {
25 + if (error) {
26 + console.log(error);
27 + }
28 + console.log([lat, lon]);
29 + for (var i = 0; i < dataNum; i++) {
30 + var latgap = (lat - results[i].latitude) * 110;
31 + var longap = (lon - results[i].longitude) * 91;
32 + var cal = latgap * latgap + longap * longap;
33 +
34 + //내 위치 반경 키로수 ^ 2만큼 cal 값 push -> content 위치
35 + if (cal <= 1600) {
36 + console.log(results[i].id);
37 + near_show_list.push([results[i].id, results[i].latitude, results[i].longitude]);
38 + }
39 + }
40 + });
41 +
42 + connection.end();
43 + // return near_show_list;
44 + }
45 +}
...@@ -9,7 +9,14 @@ router.get('/', function (req, res, next) { ...@@ -9,7 +9,14 @@ router.get('/', function (req, res, next) {
9 9
10 /* GET home page. */ 10 /* GET home page. */
11 router.get('/login', function (req, res, next) { 11 router.get('/login', function (req, res, next) {
12 - res.render('login.html', { title: 'Login1' }); 12 + res.render('login.html', { title: 'Login' });
13 console.log('로그인 페이지 접속 성공'); 13 console.log('로그인 페이지 접속 성공');
14 }); 14 });
15 +
16 +/* GET home page. */
17 +router.get('/map', function (req, res, next) {
18 + res.render('map_sql.html');
19 + console.log('현위치 기반 content 마킹 성공');
20 +});
21 +
15 module.exports = router; 22 module.exports = router;
...\ No newline at end of file ...\ No newline at end of file
......
1 +<!DOCTYPE html>
2 +<html>
3 +
4 +<head>
5 + <meta charset="utf-8">
6 + <title>geolocation으로 마커 표시하기</title>
7 +
8 +</head>
9 +
10 +<body>
11 + <p style="margin-top:-12px">
12 + <b>Chrome 브라우저는 https 환경에서만 geolocation을 지원합니다.</b> 참고해주세요.
13 + </p>
14 + <div id="map" style="width:500px;height:350px;"></div>
15 +
16 + <script type="text/javascript"
17 + src="//dapi.kakao.com/v2/maps/sdk.js?appkey=a3386042ab2e0550ea06d265855b452c">//kakao map api 주소 받아옴</script>
18 + <script>
19 + const near = require('database.js');
20 +
21 + var mapContainer = document.getElementById('map'), // 지도를 표시할 div
22 + mapOption = {
23 + center: new kakao.maps.LatLng(33.450701, 126.570667), // 지도의 중심좌표
24 + level: 10 // 지도의 확대 레벨
25 + };
26 +
27 + var map = new kakao.maps.Map(mapContainer, mapOption); // 지도를 생성합니다
28 +
29 + // HTML5의 geolocation으로 사용할 수 있는지 확인합니다
30 + if (navigator.geolocation) {
31 +
32 + // GeoLocation을 이용해서 접속 위치를 얻어옵니다
33 + navigator.geolocation.getCurrentPosition(function (position) {
34 +
35 + var lat = position.coords.latitude, // 위도
36 + lon = position.coords.longitude; // 경도
37 + console.log(lat);
38 + console.log(lon);
39 + var locPosition = new kakao.maps.LatLng(lat, lon), // 마커가 표시될 위치를 geolocation으로 얻어온 좌표로 생성합니다
40 + message = '<div style="padding:5px;">여기에 계신가요?!</div>'; // 인포윈도우에 표시될 내용입니다
41 +
42 + // 마커와 인포윈도우를 표시합니다
43 + displayMarker(locPosition, message);
44 + });
45 +
46 + } else { // HTML5의 GeoLocation을 사용할 수 없을때 마커 표시 위치와 인포윈도우 내용을 설정합니다
47 +
48 + var locPosition = new kakao.maps.LatLng(33.450701, 126.570667),
49 + message = 'geolocation을 사용할수 없어요..'
50 +
51 + displayMarker(locPosition, message);
52 + }
53 +
54 +
55 +
56 +
57 + displayShows();
58 + function displayShows() {
59 + var imageSrc = "https://t1.daumcdn.net/localimg/localimages/07/mapapidoc/markerStar.png";
60 + var near_list = near(lat, lon);
61 + var positions = [];
62 + for (var i = 0; i < near_list.length; i++) {
63 + positions.push({
64 + title: id,
65 + lating: new kakao.maps.Lating(near_list[i][1], near_list[i][2])
66 + })
67 + }
68 + for (var i = 0; i < positions.length; i++) {
69 +
70 + // 마커 이미지의 이미지 크기 입니다
71 + var imageSize = new kakao.maps.Size(24, 35);
72 +
73 + // 마커 이미지를 생성합니다
74 + var markerImage = new kakao.maps.MarkerImage(imageSrc, imageSize);
75 +
76 + // 마커를 생성합니다
77 + var marker = new kakao.maps.Marker({
78 + map: map, // 마커를 표시할 지도
79 + position: positions[i].latlng, // 마커를 표시할 위치
80 + title: positions[i].title, // 마커의 타이틀, 마커에 마우스를 올리면 타이틀이 표시됩니다
81 + image: markerImage // 마커 이미지
82 + });
83 + }
84 + }
85 + // 지도에 마커와 인포윈도우를 표시하는 함수입니다
86 + function displayMarker(locPosition, message) {
87 +
88 + // 마커를 생성합니다
89 + var marker = new kakao.maps.Marker({
90 + map: map,
91 + position: locPosition
92 + });
93 +
94 + var iwContent = message, // 인포윈도우에 표시할 내용
95 + iwRemoveable = true;
96 +
97 + // 인포윈도우를 생성합니다
98 + var infowindow = new kakao.maps.InfoWindow({
99 + content: iwContent,
100 + removable: iwRemoveable
101 + });
102 +
103 + // 인포윈도우를 마커위에 표시합니다
104 + infowindow.open(map, marker);
105 +
106 + // 지도 중심좌표를 접속위치로 변경합니다
107 + map.setCenter(locPosition);
108 + }
109 + </script>
110 +</body>
111 +
112 +</html>
...\ No newline at end of file ...\ No newline at end of file