김재현

스탬프 기능 완성

......@@ -39,16 +39,20 @@ ul.sidenav li a:hover:not(.active) {
}
table {
width: 70%;
height: 100%;
border-collapse: collapse;
text-align: center;
vertical-align: middle;
}
td {
vertical-align: middle;
text-align: center;
border: 1px solid #ddd;
padding: 15px;
width: 20%;
height: 20%;
width: 10%;
height: 0%;
padding-bottom: 20%;
background-image: url("/images/stamp.jpg");
background-repeat: no-repeat;
background-position: center top;
}
.bold {
color: #ffc0cb;
......@@ -62,7 +66,18 @@ td {
width: 15%;
display: inline-block;
float: left;
overflow: auto;
position: fixed;
background-image: url("/images/menu_icon.png");
background-repeat: no-repeat;
background-position: center top;
}
#maintitle {
text-align: center;
background: #000;
color: #fff;
padding: 80px 16px;
margin-left: 15%;
}
#mynav {
display: block;
......@@ -74,3 +89,7 @@ td {
float: left;
margin-left: 0px;
}
#map {
height: 400px;
width: 100%;
}
......
......@@ -4,8 +4,8 @@ var router = express.Router();
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : 'qmfkdnsl',
user : 'admin',
password : 'admin',
database : 'ossprojectdb'
});
......@@ -52,23 +52,24 @@ router.post('/map', function(req, res){
console.log(tempuser);
var query = connection.query('insert into users set ?',tempuser,function(err,result){
var query = connection.query('insert into history set ?',tempuser,function(err,result){
if (err) {
console.error(err);
throw err;
}
});
console.log("success insert!");
res.redirect('/map')
});
router.get('/mybook', function(req, res, next){
var rows;
var query = connection.query('select * from users',function(err,row){
var query = connection.query('select * from history h, users u WHERE h.email = u.email',function(err,row){
rows = row;
console.log(rows[1].idusers);
console.log(rows.length);
//console.log(rows[1].idusers);
//console.log(rows.length);
res.render('mybook', {title: '견문록 보기', rows: rows});
});
......@@ -76,6 +77,21 @@ router.get('/mybook', function(req, res, next){
});
router.get('/history', function(req, res, next){
var rows;
var query = connection.query('select contentid from history h, users u WHERE h.email = u.email',function(err,row){
rows = row;
//console.log(rows[1].idusers);
//console.log(rows.length);
res.send({rows: rows});
});
});
router.get('/test', function(req, res, next){
res.render('test', {title: 'test'});
......
......@@ -42,18 +42,40 @@
radius: 1000,
type: ['restaurant']
}, callback);
var resultsSet = null;
$.ajax({
type : "GET",
url : "/history",
dataType : "json",
error : function(){
alert('통신실패!!');
},
success : function(data){
resultsSet = data;
}
});
function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
createMarker(results[i], resultsSet);
}
}
}
function createMarker(place) {
function createMarker(place,resultsSet) {
var image1 = 'http://localhost:3000/images/restaurant_1.png'
var image2 = 'http://localhost:3000/images/restaurant_2.png'
var isMarked = false;
for (var i = 0; i < resultsSet.rows.length; i++) {
if(resultsSet.rows[i].contentid == place.id)
isMarked = true;
}
var placeLoc = place.geometry.location;
var marker1 = new google.maps.Marker({
map: map,
......@@ -65,7 +87,15 @@
position: place.geometry.location,
icon: image2
});
if(isMarked==true){
marker1.setMap(null);
}
else{
marker2.setMap(null);
}
var contentString = '<div id="content">'+
'<div id="siteNotice">'+
......@@ -79,6 +109,16 @@
'</div>'+
'</div>';
var contentString2 = '<div id="content">'+
'<div id="siteNotice">'+
'</div>'+
'<h1 id="firstHeading" class="firstHeading">'+place.name+'</h1>'+
'<div id="bodyContent">'+
'<p>주소: '+place.vicinity+'<br/>'+
'</p>'+
'</div>'+
'</div>';
google.maps.event.addListener(marker1, 'click', function(e) {
......@@ -92,7 +132,7 @@
});
google.maps.event.addListener(marker2, 'click', function() {
var infowindow = new google.maps.InfoWindow({
content: contentString,
content: contentString2,
maxWidth: 300
});
infowindow.open(map, this);
......