map.ejs
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<!DOCTYPE html>
<html>
<head>
<title>KaKao Map</title>
<link rel="stylesheet" href="/stylesheets/style.css" />
</head>
<body>
<div id="map" style="width: 100%; height: 575px"></div>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee"
></script>
<script>
var lat = "";
var lon = "";
var mapContainer = document.getElementById("map"),
mapOption = {
center: new kakao.maps.LatLng(36.2477502, 127.078164),
level: 3,
};
var map = new kakao.maps.Map(mapContainer, mapOption);
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function (position) {
lat = position.coords.latitude;
lon = position.coords.longitude;
var locPosition = new kakao.maps.LatLng(lat, lon);
displayMarker(locPosition);
});
} else {
var locPosition = new kakao.maps.LatLng(36.2477502, 127.078164);
displayMarker(locPosition);
}
function displayMarker(locPosition) {
var marker = new daum.maps.Marker({
map: map,
position: locPosition,
});
map.setCenter(locPosition);
}
</script>
</body>
</html>