Showing
3 changed files
with
53 additions
and
55 deletions
... | @@ -9,59 +9,6 @@ | ... | @@ -9,59 +9,6 @@ |
9 | type="text/javascript" | 9 | type="text/javascript" |
10 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=17cbb7795b615d8f1f0595f972e26c0f&libraries=services,clusterer,drawing" | 10 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=17cbb7795b615d8f1f0595f972e26c0f&libraries=services,clusterer,drawing" |
11 | ></script> | 11 | ></script> |
12 | - <script> | 12 | + <script type="text/javascript" src="../js/next_page.js"></script> |
13 | - var Container = document.getElementById("map"); | ||
14 | - var Option = { | ||
15 | - center: new kakao.maps.LatLng(33.450701, 126.570667), | ||
16 | - level: 5, | ||
17 | - }; | ||
18 | - | ||
19 | - var map = new kakao.maps.Map(Container, Option); | ||
20 | - resizeMap(); | ||
21 | - relayout(); | ||
22 | - | ||
23 | - function resizeMap() { | ||
24 | - var Container = document.getElementById("map"); | ||
25 | - Container.style.width = "600px"; | ||
26 | - Container.style.height = "500px"; | ||
27 | - } | ||
28 | - | ||
29 | - function relayout() { | ||
30 | - map.relayout(); | ||
31 | - } | ||
32 | - | ||
33 | - if (navigator.geolocation) { | ||
34 | - navigator.geolocation.getCurrentPosition(function (position) { | ||
35 | - var latitude = position.coords.latitude, | ||
36 | - longitude = position.coords.longitude; | ||
37 | - var Position = new kakao.maps.LatLng(latitude, longitude); | ||
38 | - displayMarker(Position); | ||
39 | - }); | ||
40 | - } | ||
41 | - | ||
42 | - function displayMarker(Position) { | ||
43 | - var marker = new kakao.maps.Marker({ | ||
44 | - map: map, | ||
45 | - position: Position, | ||
46 | - }); | ||
47 | - | ||
48 | - map.setCenter(Position); | ||
49 | - function getParameterByName(name, url = window.location.href) { | ||
50 | - name = name.replace(/[\[\]]/g, "\\$&"); | ||
51 | - var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
52 | - results = regex.exec(url); | ||
53 | - if (!results) return null; | ||
54 | - if (!results[2]) return ""; | ||
55 | - return decodeURIComponent(results[2].replace(/\+/g, " ")); | ||
56 | - } | ||
57 | - var salary = getParameterByName("salary"); | ||
58 | - var expenditure = getParameterByName("expenditure"); | ||
59 | - console.log(salary); | ||
60 | - var year = "3"; | ||
61 | - var div = document.createElement("div"); | ||
62 | - div.innerText = `${salary}의 월급과 ${expenditure}의 지출을 유지하면 당신은 ${year}년 후에 아래의 집을 구매할 수 있습니다.`; | ||
63 | - document.body.prepend(div); | ||
64 | - } | ||
65 | - </script> | ||
66 | </body> | 13 | </body> |
67 | </html> | 14 | </html> | ... | ... |
public/js/next_page.js
0 → 100644
1 | +var Container = document.getElementById("map"); | ||
2 | +var Option = { | ||
3 | + center: new kakao.maps.LatLng(33.450701, 126.570667), | ||
4 | + level: 5, | ||
5 | +}; | ||
6 | + | ||
7 | +var map = new kakao.maps.Map(Container, Option); | ||
8 | +resizeMap(); | ||
9 | +relayout(); | ||
10 | + | ||
11 | +function resizeMap() { | ||
12 | + var Container = document.getElementById("map"); | ||
13 | + Container.style.width = "600px"; | ||
14 | + Container.style.height = "500px"; | ||
15 | +} | ||
16 | + | ||
17 | +function relayout() { | ||
18 | + map.relayout(); | ||
19 | +} | ||
20 | + | ||
21 | +if (navigator.geolocation) { | ||
22 | + navigator.geolocation.getCurrentPosition(function (position) { | ||
23 | + var latitude = position.coords.latitude, | ||
24 | + longitude = position.coords.longitude; | ||
25 | + var Position = new kakao.maps.LatLng(latitude, longitude); | ||
26 | + displayMarker(Position); | ||
27 | + }); | ||
28 | +} | ||
29 | + | ||
30 | +function displayMarker(Position) { | ||
31 | + var marker = new kakao.maps.Marker({ | ||
32 | + map: map, | ||
33 | + position: Position, | ||
34 | + }); | ||
35 | + | ||
36 | + map.setCenter(Position); | ||
37 | + function getParameterByName(name, url = window.location.href) { | ||
38 | + name = name.replace(/[\[\]]/g, "\\$&"); | ||
39 | + var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), | ||
40 | + results = regex.exec(url); | ||
41 | + if (!results) return null; | ||
42 | + if (!results[2]) return ""; | ||
43 | + return decodeURIComponent(results[2].replace(/\+/g, " ")); | ||
44 | + } | ||
45 | + var salary = getParameterByName("salary"); | ||
46 | + var expenditure = getParameterByName("expenditure"); | ||
47 | + var year = "3"; //값 받아오기 전 기본값으로 설정 | ||
48 | + var div = document.createElement("div"); | ||
49 | + div.innerText = `${salary}의 월급과 ${expenditure}의 지출을 유지하면 당신은 ${year}년 후에 아래의 집을 구매할 수 있습니다.`; | ||
50 | + document.body.prepend(div); | ||
51 | +} |
... | @@ -15,6 +15,6 @@ app.get("/", function (req, res) { | ... | @@ -15,6 +15,6 @@ app.get("/", function (req, res) { |
15 | res.sendFile(path.join(__dirname + "/main.html")); | 15 | res.sendFile(path.join(__dirname + "/main.html")); |
16 | }); | 16 | }); |
17 | 17 | ||
18 | -app.post("/geolocation", function (req, res) { | 18 | +app.get("/geolocation", function (req, res) { |
19 | res.sendFile(path.join(__dirname + "/kakao/kakaomap.html")); | 19 | res.sendFile(path.join(__dirname + "/kakao/kakaomap.html")); |
20 | }); | 20 | }); | ... | ... |
-
Please register or login to post a comment