Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김재현
/
open-source-project-2017-02
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김정은
2017-12-07 12:39:19 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
39c842f65df5999d907e235d0530f8adbe746699
39c842f6
1 parent
9d768be8
forming() is submit
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
27 deletions
app.js
routes/index.js
views/map.ejs
app.js
View file @
39c842f
var
express
=
require
(
'express'
);
var
mysql
=
require
(
'mysql'
);
var
path
=
require
(
'path'
);
var
favicon
=
require
(
'serve-favicon'
);
var
logger
=
require
(
'morgan'
);
...
...
@@ -11,12 +11,7 @@ var index = require('./routes/index');
var
users
=
require
(
'./routes/users'
);
var
app
=
express
();
var
connection
=
mysql
.
createConnection
({
host
:
'localhost'
,
user
:
'admin'
,
password
:
'admin'
,
database
:
'ossprojectdb'
});
// view engine setup
app
.
set
(
'views'
,
path
.
join
(
__dirname
,
'views'
));
...
...
@@ -54,24 +49,15 @@ app.use(function(err, req, res, next) {
module
.
exports
=
app
;
/*
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'localhost',
user : 'admin',
password : 'admin',
database : 'ossprojectdb'
});
connection.connect();
connection.query('SELECT * from users', function(err, rows, fields) {
if (!err)
console.log('The solution is: ', rows);
else
console.log('Error while performing Query.');
});
connection.end();
*/
//
// connection.query('SELECT * from users', function(err, rows, fields) {
// if (!err)
// console.log('The solution is: ', rows);
// else
// console.log('Error while performing Query.');
// });
//
// connection.end();
...
...
routes/index.js
View file @
39c842f
var
express
=
require
(
'express'
);
var
mysql
=
require
(
'mysql'
);
var
router
=
express
.
Router
();
var
connection
=
mysql
.
createConnection
({
host
:
'localhost'
,
user
:
'root'
,
password
:
'qmfkdnsl'
,
database
:
'ossprojectdb'
});
connection
.
connect
();
/* GET home page. */
router
.
get
(
'/index'
,
function
(
req
,
res
,
next
)
{
res
.
render
(
'index'
,
{
title
:
'Express'
});
...
...
@@ -13,15 +22,44 @@ router.get('/', function(req, res, next) {
router
.
get
(
'/map'
,
function
(
req
,
res
,
next
){
res
.
render
(
'map'
,
{
title
:
'맛집 도장찍기'
});
var
user
=
{
iduser
:
"abc"
,
username
:
"김정은"
,
password
:
"qmfkdnsl"
,
email
:
"bfghg@naver.com"
}
res
.
render
(
'map'
,
{
title
:
'맛집 도장찍기'
,
user
:
user
});
});
router
.
get
(
'/home'
,
function
(
req
,
res
,
next
){
res
.
render
(
'main'
,
{
title
:
'맛집견문록'
});
});
router
.
post
(
'/map'
,
function
(
req
,
res
){
var
tempuser
=
{
'idusers'
:
req
.
body
.
userid
,
'address'
:
req
.
body
.
placeaddress
,
'contendid'
:
req
.
body
.
placeid
,
'title'
:
req
.
body
.
placename
}
console
.
log
(
tempuser
);
var
query
=
connection
.
query
(
'insert into users set ?'
,
tempuser
,
function
(
err
,
result
){
if
(
err
)
{
console
.
error
(
err
);
throw
err
;
}
console
.
log
(
query
);
});
});
router
.
get
(
'/mybook'
,
function
(
req
,
res
,
next
){
...
...
@@ -59,3 +97,4 @@ res.render('test', {title: 'test'});
});
module
.
exports
=
router
;
connection
.
end
();
...
...
views/map.ejs
View file @
39c842f
...
...
@@ -6,6 +6,24 @@
<script
async
defer
src=
"https://maps.googleapis.com/maps/api/js?key=AIzaSyBTR69UvS1403rvBcM64_8nlzpKLv23RIE&libraries=places"
></script>
<script>
//표시하기 버튼 눌렀을 때 post보내는 함수
function
forming
()
{
console
.
log
(
place
)
if
(
confirm
(
"맛집견문록에 기록하겠습니까?"
)){
document
.
forms
[
"userform"
].
submit
();
return
true
;
}
else
{
return
false
;
}
}
function
initMap
(
latitude
,
longitude
)
{
var
center
=
{
lat
:
latitude
,
lng
:
longitude
};
...
...
@@ -59,15 +77,22 @@
'<h1 id="firstHeading" class="firstHeading">'
+
place
.
name
+
'</h1>'
+
'<div id="bodyContent">'
+
'<p>주소: '
+
place
.
vicinity
+
'<br/>'
+
'<a href="
https://localhost:3000/id='
+
place
.
id
+
'
">'
+
'<a href="
#" onclick="forming();
">'
+
'표시하기</a> '
+
'</p>'
+
'</div>'
+
'</div>'
;
google
.
maps
.
event
.
addListener
(
marker1
,
'click'
,
function
(
e
)
{
//console.log(place)
var
infowindow
=
new
google
.
maps
.
InfoWindow
({
content
:
contentString
,
maxWidth
:
300
...
...
@@ -75,6 +100,13 @@
infowindow
.
open
(
map
,
this
);
//marker1.setMap(null);
//marker2.setMap(map);
console
.
log
(
'<%=user.username%>'
);
// console.log(document.getElementsByName('placeaddress').value);
});
google
.
maps
.
event
.
addListener
(
marker2
,
'click'
,
function
()
{
var
infowindow
=
new
google
.
maps
.
InfoWindow
({
...
...
@@ -99,6 +131,8 @@
$nav
.
toggleClass
(
'open'
);
});
$
(
"input[name=first_name]"
);
if
(
"geolocation"
in
navigator
)
{
navigator
.
geolocation
.
getCurrentPosition
(
function
(
position
)
{
//console.log(position.coords.latitude)
...
...
@@ -131,6 +165,16 @@
<div
id =
"content"
>
<div
id=
"map"
></div>
<div
id=
"popup"
></div>
<div
id=
"form"
>
<form
name=
"userform"
method=
"POST"
action=
"/map"
>
<input
type=
"hidden"
name=
"userid"
/>
<input
type=
"hidden"
name=
"placeid"
/>
<input
type=
"hidden"
name=
"placename"
/>
<input
type=
"hidden"
name=
"placeaddress"
/>
</form>
</div>
</div>
<div
id =
"footer"
></div>
...
...
Please
register
or
login
to post a comment