김재현

스탬프 기능 완성

...@@ -39,16 +39,20 @@ ul.sidenav li a:hover:not(.active) { ...@@ -39,16 +39,20 @@ ul.sidenav li a:hover:not(.active) {
39 } 39 }
40 table { 40 table {
41 width: 70%; 41 width: 70%;
42 - height: 100%;
43 border-collapse: collapse; 42 border-collapse: collapse;
44 text-align: center; 43 text-align: center;
44 + vertical-align: middle;
45 } 45 }
46 td { 46 td {
47 + vertical-align: middle;
47 text-align: center; 48 text-align: center;
48 border: 1px solid #ddd; 49 border: 1px solid #ddd;
49 - padding: 15px; 50 + width: 10%;
50 - width: 20%; 51 + height: 0%;
51 - height: 20%; 52 + padding-bottom: 20%;
53 + background-image: url("/images/stamp.jpg");
54 + background-repeat: no-repeat;
55 + background-position: center top;
52 } 56 }
53 .bold { 57 .bold {
54 color: #ffc0cb; 58 color: #ffc0cb;
...@@ -62,7 +66,18 @@ td { ...@@ -62,7 +66,18 @@ td {
62 width: 15%; 66 width: 15%;
63 display: inline-block; 67 display: inline-block;
64 float: left; 68 float: left;
65 - 69 + overflow: auto;
70 + position: fixed;
71 + background-image: url("/images/menu_icon.png");
72 + background-repeat: no-repeat;
73 + background-position: center top;
74 +}
75 +#maintitle {
76 + text-align: center;
77 + background: #000;
78 + color: #fff;
79 + padding: 80px 16px;
80 + margin-left: 15%;
66 } 81 }
67 #mynav { 82 #mynav {
68 display: block; 83 display: block;
...@@ -74,3 +89,7 @@ td { ...@@ -74,3 +89,7 @@ td {
74 float: left; 89 float: left;
75 margin-left: 0px; 90 margin-left: 0px;
76 } 91 }
92 +#map {
93 + height: 400px;
94 + width: 100%;
95 +}
......
...@@ -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);
......