Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오지민
/
HomePurchaseAgePrediction
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
Ojimin
2021-06-09 10:33:17 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d64e9f14da3d063b68fa94f83c91a83afcefc11b
d64e9f14
1 parent
164cf21d
Connect with db
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
75 additions
and
18 deletions
.gitignore
API/.gitkeep
API/api.js
package.json
public/js/next_page.js
server.js
.gitignore
View file @
d64e9f1
node_modules/
package-lock.json
\ No newline at end of file
package-lock.json
#database
database.json
\ No newline at end of file
...
...
API/.gitkeep
deleted
100644 → 0
View file @
164cf21
File mode changed
API/api.js
deleted
100644 → 0
View file @
164cf21
var
request
=
require
(
'request'
);
var
url
=
'http://openapi.molit.go.kr/OpenAPI_ToolInstallPackage/service/rest/RTMSOBJSvc/getRTMSDataSvcLandTrade'
;
var
queryParams
=
'?'
+
encodeURIComponent
(
'ServiceKey'
)
+
'=aOirrPIaJrx9RbuDcSM5rE3zzWUmbTaR2nAU4AcdQT2cFkJlG1ZeKa%2FlVF8wHFJthJT6C3jeS5n%2FP%2B3pBggZrw%3D%3D'
;
/* Service Key*/
queryParams
+=
'&'
+
encodeURIComponent
(
'LAWD_CD'
)
+
'='
+
encodeURIComponent
(
'11110'
);
/* */
queryParams
+=
'&'
+
encodeURIComponent
(
'DEAL_YMD'
)
+
'='
+
encodeURIComponent
(
'201512'
);
/* */
request
({
url
:
url
+
queryParams
,
method
:
'GET'
},
function
(
error
,
response
,
body
)
{
console
.
log
(
'Status'
,
response
.
statusCode
);
console
.
log
(
'Headers'
,
JSON
.
stringify
(
response
.
headers
));
console
.
log
(
'Reponse received'
,
body
);
});
package.json
View file @
d64e9f1
...
...
@@ -10,6 +10,7 @@
"license"
:
"ISC"
,
"dependencies"
:
{
"express"
:
"^4.17.1"
,
"mysql"
:
"^2.18.1"
,
"path"
:
"^0.12.7"
,
"request"
:
"^2.88.2"
}
...
...
public/js/next_page.js
View file @
d64e9f1
...
...
@@ -13,7 +13,7 @@ function resizeMap() {
Container
.
style
.
width
=
"400px"
;
Container
.
style
.
height
=
"300px"
;
}
function
relayout
()
{
map
.
relayout
();
}
...
...
@@ -27,6 +27,53 @@ if (navigator.geolocation) {
});
}
//db에서 데이터 받아오면 구현할 부분
/*
// 마커를 표시할 위치와 내용을 가지고 있는 객체 배열입니다
var positions = results;
// 주소-좌표 변환 객체를 생성합니다
var geocoder = new kakao.maps.services.Geocoder();
for (var i = 0; i < positions.length; i ++) {
// 주소로 좌표를 검색합니다
geocoder.addressSearch(positions[i].add_address, function(result, status) {
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
var coords = new kakao.maps.LatLng(result[0].y, result[0].x);
// 결과값으로 받은 위치를 마커로 표시합니다
var marker = new kakao.maps.Marker({
map: map,
position: coords
});
// 마커에 표시할 인포윈도우를 생성합니다
var infowindow = new kakao.maps.InfoWindow({
content: positions[i].amount // 인포윈도우에 표시할 내용
});
// 마커에 mouseover 이벤트와 mouseout 이벤트를 등록합니다
// 이벤트 리스너로는 클로저를 만들어 등록합니다
// for문에서 클로저를 만들어 주지 않으면 마지막 마커에만 이벤트가 등록됩니다
kakao.maps.event.addListener(marker, 'mouseover', makeOverListener(map, marker, infowindow));
kakao.maps.event.addListener(marker, 'mouseout', makeOutListener(infowindow));
}
});
}
// 인포윈도우를 표시하는 클로저를 만드는 함수입니다
function makeOverListener(map, marker, infowindow) {
return function() {
infowindow.open(map, marker);
};
}
// 인포윈도우를 닫는 클로저를 만드는 함수입니다
function makeOutListener(infowindow) {
return function() {
infowindow.close();
};
}
*/
function
displayMarker
(
Position
)
{
var
marker
=
new
kakao
.
maps
.
Marker
({
map
:
map
,
...
...
@@ -49,4 +96,6 @@ function displayMarker(Position) {
var
year
=
"3"
;
//값 받아오기 전 기본값으로 설정
var
div
=
document
.
getElementById
(
"info"
);
div
.
innerText
=
`
${
salary
}
만원의 월급과
${
expenditure
}
만원의 지출을 유지하면 당신은
${
year
}
년 후 아래의 집을 구매할 수 있습니다.`
;
connection
.
end
();
}
...
...
server.js
View file @
d64e9f1
...
...
@@ -7,15 +7,35 @@ const app = express();
const
domain
=
"2020105619.oss2021.tk"
;
const
sslport
=
8080
;
const
data
=
fs
.
readFileSync
(
'database.json'
);
const
conf
=
JSON
.
parse
(
data
);
const
mysql
=
require
(
'mysql'
);
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
"kakao"
)));
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
"public"
)));
const
connection
=
mysql
.
createConnection
({
host
:
conf
.
host
,
user
:
conf
.
user
,
password
:
conf
.
password
,
port
:
conf
.
port
,
database
:
conf
.
database
});
connection
.
connect
();
app
.
get
(
"/"
,
function
(
req
,
res
)
{
res
.
sendFile
(
path
.
join
(
__dirname
+
"/main.html"
));
});
app
.
get
(
"/geolocation"
,
function
(
req
,
res
)
{
res
.
sendFile
(
path
.
join
(
__dirname
+
"/kakao/kakaomap.html"
));
connection
.
query
(
'SELECT * FROM csvdata.csvdata'
,
function
(
error
,
results
,
fields
)
{
if
(
error
)
{
throw
(
error
);
}
res
.
send
(
results
);
});
});
try
{
...
...
Please
register
or
login
to post a comment