서연진

서버 오류 수정, js파일 생성

......@@ -9,59 +9,6 @@
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);
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return "";
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var salary = getParameterByName("salary");
var expenditure = getParameterByName("expenditure");
console.log(salary);
var year = "3";
var div = document.createElement("div");
div.innerText = `${salary}의 월급과 ${expenditure}의 지출을 유지하면 당신은 ${year}년 후에 아래의 집을 구매할 수 있습니다.`;
document.body.prepend(div);
}
</script>
<script type="text/javascript" src="../js/next_page.js"></script>
</body>
</html>
......
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);
function getParameterByName(name, url = window.location.href) {
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return "";
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
var salary = getParameterByName("salary");
var expenditure = getParameterByName("expenditure");
var year = "3"; //값 받아오기 전 기본값으로 설정
var div = document.createElement("div");
div.innerText = `${salary}의 월급과 ${expenditure}의 지출을 유지하면 당신은 ${year}년 후에 아래의 집을 구매할 수 있습니다.`;
document.body.prepend(div);
}
......@@ -15,6 +15,6 @@ app.get("/", function (req, res) {
res.sendFile(path.join(__dirname + "/main.html"));
});
app.post("/geolocation", function (req, res) {
app.get("/geolocation", function (req, res) {
res.sendFile(path.join(__dirname + "/kakao/kakaomap.html"));
});
......