김민기

카카오맵 띄우기 1차

node_modules/
package-lock.json
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTR-8">
</head>
<body>
<h1>전달받은 데이터</h1>
<ul>
<li>연봉: (????) 만 원</li>
<li>지출: (????) 만 원</li>
</ul>
<div id="map" style="float:right"></div>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=17cbb7795b615d8f1f0595f972e26c0f&libraries=services,clusterer,drawing"
></script>
<script>
var Container = document.getElementById("map")
var Option = {
center: new kakao.maps.LatLng(33.450701, 126.570667),
level: 5,
};
var map = new kakao.maps.Map(Container, Option);
resizeMap();
relayout();
function resizeMap() {
var Container = document.getElementById('map');
Container.style.width = '600px';
Container.style.height = '500px';
}
function relayout() {
map.relayout();
}
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
var latitude = position.coords.latitude, longitude = position.coords.longitude;
var Position = new kakao.maps.LatLng(latitude, longitude);
displayMarker(Position);
});
}
function displayMarker(Position) {
var marker = new kakao.maps.Marker({
map: map,
position: Position,
});
map.setCenter(Position);
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -20,7 +20,7 @@
사용자의 위치기반으로 집 구매 시기를 예측해드립니다 (사용자 위치 근처의
집을 찾아드립니다)
</h4>
<form action="result" method="POST">
<form action="/geolocation" method = "POST">
<div>
연봉(단위:만 원)
<input
......
{
"name": "map-api",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"path": "^0.12.7",
"request": "^2.88.2"
}
}
const express = require('express');
const path = require('path');
const request = require('request');
const app = express();
app.use(express.static(path.join(__dirname,'kakao')));
app.listen(8080, function(req,res) {
console.log("server started at 8080");
});
app.get('/', function(req,res){
res.sendFile(path.join(__dirname+"/main.html"));
});
app.post('/geolocation', function(req,res){
res.sendFile(path.join(__dirname+"/kakao/kakaomap.html"));
});
\ No newline at end of file