Showing
3 changed files
with
67 additions
and
11 deletions
... | @@ -13,7 +13,7 @@ ul.sidenav | ... | @@ -13,7 +13,7 @@ ul.sidenav |
13 | width: 15%; | 13 | width: 15%; |
14 | background-color: #f1f1f1; | 14 | background-color: #f1f1f1; |
15 | height: 100%; | 15 | height: 100%; |
16 | - position : fixed; | 16 | + position : fixed;s |
17 | overflow : auto; | 17 | overflow : auto; |
18 | 18 | ||
19 | ul.sidenav li a | 19 | ul.sidenav li a | ... | ... |
... | @@ -4,8 +4,8 @@ var router = express.Router(); | ... | @@ -4,8 +4,8 @@ var router = express.Router(); |
4 | 4 | ||
5 | var connection = mysql.createConnection({ | 5 | var connection = mysql.createConnection({ |
6 | host : 'localhost', | 6 | host : 'localhost', |
7 | - user : 'root', | 7 | + user : 'admin', |
8 | - password : 'qmfkdnsl', | 8 | + password : 'admin', |
9 | database : 'ossprojectdb' | 9 | database : 'ossprojectdb' |
10 | }); | 10 | }); |
11 | 11 | ||
... | @@ -52,23 +52,24 @@ router.post('/map', function(req, res){ | ... | @@ -52,23 +52,24 @@ router.post('/map', function(req, res){ |
52 | 52 | ||
53 | console.log(tempuser); | 53 | console.log(tempuser); |
54 | 54 | ||
55 | - var query = connection.query('insert into users set ?',tempuser,function(err,result){ | 55 | + var query = connection.query('insert into history set ?',tempuser,function(err,result){ |
56 | if (err) { | 56 | if (err) { |
57 | console.error(err); | 57 | console.error(err); |
58 | throw err; | 58 | throw err; |
59 | } | 59 | } |
60 | }); | 60 | }); |
61 | console.log("success insert!"); | 61 | console.log("success insert!"); |
62 | + res.redirect('/map') | ||
62 | }); | 63 | }); |
63 | 64 | ||
64 | router.get('/mybook', function(req, res, next){ | 65 | router.get('/mybook', function(req, res, next){ |
65 | 66 | ||
66 | var rows; | 67 | var rows; |
67 | - var query = connection.query('select * from users',function(err,row){ | 68 | + var query = connection.query('select * from history h, users u WHERE h.email = u.email',function(err,row){ |
68 | 69 | ||
69 | rows = row; | 70 | rows = row; |
70 | - console.log(rows[1].idusers); | 71 | + //console.log(rows[1].idusers); |
71 | - console.log(rows.length); | 72 | + //console.log(rows.length); |
72 | res.render('mybook', {title: '견문록 보기', rows: rows}); | 73 | res.render('mybook', {title: '견문록 보기', rows: rows}); |
73 | 74 | ||
74 | }); | 75 | }); |
... | @@ -76,6 +77,21 @@ router.get('/mybook', function(req, res, next){ | ... | @@ -76,6 +77,21 @@ router.get('/mybook', function(req, res, next){ |
76 | 77 | ||
77 | }); | 78 | }); |
78 | 79 | ||
80 | +router.get('/history', function(req, res, next){ | ||
81 | + | ||
82 | + var rows; | ||
83 | + var query = connection.query('select contentid from history h, users u WHERE h.email = u.email',function(err,row){ | ||
84 | + | ||
85 | + rows = row; | ||
86 | + //console.log(rows[1].idusers); | ||
87 | + //console.log(rows.length); | ||
88 | + res.send({rows: rows}); | ||
89 | + | ||
90 | + }); | ||
91 | + | ||
92 | + | ||
93 | +}); | ||
94 | + | ||
79 | router.get('/test', function(req, res, next){ | 95 | router.get('/test', function(req, res, next){ |
80 | 96 | ||
81 | res.render('test', {title: 'test'}); | 97 | res.render('test', {title: 'test'}); | ... | ... |
... | @@ -42,18 +42,40 @@ | ... | @@ -42,18 +42,40 @@ |
42 | radius: 1000, | 42 | radius: 1000, |
43 | type: ['restaurant'] | 43 | type: ['restaurant'] |
44 | }, callback); | 44 | }, callback); |
45 | + | ||
46 | + var resultsSet = null; | ||
47 | + | ||
48 | + $.ajax({ | ||
49 | + type : "GET", | ||
50 | + url : "/history", | ||
51 | + dataType : "json", | ||
52 | + error : function(){ | ||
53 | + alert('통신실패!!'); | ||
54 | + }, | ||
55 | + success : function(data){ | ||
56 | + resultsSet = data; | ||
57 | + } | ||
58 | + | ||
59 | + }); | ||
60 | + | ||
45 | function callback(results, status) { | 61 | function callback(results, status) { |
46 | if (status === google.maps.places.PlacesServiceStatus.OK) { | 62 | if (status === google.maps.places.PlacesServiceStatus.OK) { |
47 | for (var i = 0; i < results.length; i++) { | 63 | for (var i = 0; i < results.length; i++) { |
48 | - createMarker(results[i]); | 64 | + createMarker(results[i], resultsSet); |
49 | } | 65 | } |
50 | } | 66 | } |
51 | } | 67 | } |
52 | 68 | ||
53 | - function createMarker(place) { | 69 | + function createMarker(place,resultsSet) { |
54 | var image1 = 'http://localhost:3000/images/restaurant_1.png' | 70 | var image1 = 'http://localhost:3000/images/restaurant_1.png' |
55 | var image2 = 'http://localhost:3000/images/restaurant_2.png' | 71 | var image2 = 'http://localhost:3000/images/restaurant_2.png' |
56 | 72 | ||
73 | + var isMarked = false; | ||
74 | + for (var i = 0; i < resultsSet.rows.length; i++) { | ||
75 | + if(resultsSet.rows[i].contentid == place.id) | ||
76 | + isMarked = true; | ||
77 | + } | ||
78 | + | ||
57 | var placeLoc = place.geometry.location; | 79 | var placeLoc = place.geometry.location; |
58 | var marker1 = new google.maps.Marker({ | 80 | var marker1 = new google.maps.Marker({ |
59 | map: map, | 81 | map: map, |
... | @@ -65,7 +87,15 @@ | ... | @@ -65,7 +87,15 @@ |
65 | position: place.geometry.location, | 87 | position: place.geometry.location, |
66 | icon: image2 | 88 | icon: image2 |
67 | }); | 89 | }); |
68 | - marker2.setMap(null); | 90 | + if(isMarked==true){ |
91 | + marker1.setMap(null); | ||
92 | + } | ||
93 | + else{ | ||
94 | + marker2.setMap(null); | ||
95 | + } | ||
96 | + | ||
97 | + | ||
98 | + | ||
69 | 99 | ||
70 | var contentString = '<div id="content">'+ | 100 | var contentString = '<div id="content">'+ |
71 | '<div id="siteNotice">'+ | 101 | '<div id="siteNotice">'+ |
... | @@ -79,6 +109,16 @@ | ... | @@ -79,6 +109,16 @@ |
79 | '</div>'+ | 109 | '</div>'+ |
80 | '</div>'; | 110 | '</div>'; |
81 | 111 | ||
112 | + var contentString2 = '<div id="content">'+ | ||
113 | + '<div id="siteNotice">'+ | ||
114 | + '</div>'+ | ||
115 | + '<h1 id="firstHeading" class="firstHeading">'+place.name+'</h1>'+ | ||
116 | + '<div id="bodyContent">'+ | ||
117 | + '<p>주소: '+place.vicinity+'<br/>'+ | ||
118 | + '</p>'+ | ||
119 | + '</div>'+ | ||
120 | + '</div>'; | ||
121 | + | ||
82 | 122 | ||
83 | 123 | ||
84 | google.maps.event.addListener(marker1, 'click', function(e) { | 124 | google.maps.event.addListener(marker1, 'click', function(e) { |
... | @@ -92,7 +132,7 @@ | ... | @@ -92,7 +132,7 @@ |
92 | }); | 132 | }); |
93 | google.maps.event.addListener(marker2, 'click', function() { | 133 | google.maps.event.addListener(marker2, 'click', function() { |
94 | var infowindow = new google.maps.InfoWindow({ | 134 | var infowindow = new google.maps.InfoWindow({ |
95 | - content: contentString, | 135 | + content: contentString2, |
96 | maxWidth: 300 | 136 | maxWidth: 300 |
97 | }); | 137 | }); |
98 | infowindow.open(map, this); | 138 | infowindow.open(map, this); | ... | ... |
-
Please register or login to post a comment