김정은

머지 진행

......@@ -13,7 +13,7 @@ ul.sidenav
width: 15%;
background-color: #f1f1f1;
height: 100%;
position : fixed;
position : fixed;s
overflow : auto;
ul.sidenav li a
......
......@@ -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
});
marker2.setMap(null);
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);
......