dckat

중심좌표 현재위치로 구현

{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1620820123092,"user":{"name":"‍김대철[학생](소프트웨어융합대학 컴퓨터공학과)","email":"kdc9619@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJyP14ipRboJZ8T5-oNS3sRp4CG8wKCEwVABQ5G_=s96-c"}}
\ No newline at end of file
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1620823546959,"user":{"name":"‍김대철[학생](소프트웨어융합대학 컴퓨터공학과)","email":"kdc9619@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJyP14ipRboJZ8T5-oNS3sRp4CG8wKCEwVABQ5G_=s96-c"}}
\ No newline at end of file
......
......@@ -12,13 +12,40 @@
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee"
></script>
<script>
const mapContainer = document.getElementById("map"),
var lat = "";
var lon = "";
var mapContainer = document.getElementById("map"),
mapOption = {
center: new kakao.maps.LatLng(37.2477502, 127.078164),
center: new kakao.maps.LatLng(36.2477502, 127.078164),
level: 3,
};
const map = new kakao.maps.Map(mapContainer, mapOption);
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>
......