• 카테고리

    질문 & 답변
  • 세부 분야

    풀스택

  • 해결 여부

    미해결

별다른 오류창 없이 마커가 송출되지 않습니다

21.08.17 13:31 작성 조회수 133

0

index.ejs
var data = [
{
title: "서울",
content: "서울 남산",
date: "2021-07-02",
lat: 37.515145,
lng: 127.035393,
},
{
title: "서울2",
content: "서울 용산",
date: "2021-07-20",
lat: 37.515000,
lng: 127.016676,
}
]
index.ejs
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<title>myfirstmap</title>
<link rel="stylesheet" href="/stylesheets/style.css" />
<script type="text/javascript"
src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=xme01nth90"></script>
</head>

<body>
<div id="navber">myfirstmap</div>
<div id="infobox">
<div id="infotitle">현재날짜</div>
<div id="infocontent">today</div>
</div>

<div id="map" style="width:100%;height:100vh;"></div>
<script type="text/javascript" src="/myfirstmap/public/data/data.js"></script>
<script>
var mapOptions = {
center: new naver.maps.LatLng(37.3595704, 127.105399),
zoom: 10
};
var map = new naver.maps.Map('map', mapOptions);

for (var i in data){
var target = data[i];
var latlng = new naver.map.Latlng(target.lat, target.lng);
Marker = new naver.maps.Marker({
map: map,
position: latlng,
icon: {
content: "<div class='Marker'></div>",
},
});
}

</script>
</body>
</html>
style css
body {
padding: 0px !important ;
margin: 0px !important ;
}

#navber {
height: 50px;
width: 100%;
background: #262626;
color: white;
font-weight: bolder;
font-size: 25px;
display: flex;
justify-content: center;
align-items: center;
}

#infobox {
position : absolute;
top: 100px;
z-index: 10000;
background: white;
left: 20px;
padding: 15px;
border: 1px solid rgba(0, 0, 0, 0.2);
}

#infotitle {
font-size: 15px;
font-weight: bolder;
}

.Marker {
border: 1px solid black;
background: green;
opacity: 0.8;
width: 24px;
height: 24px;
border-radius: 50%;
}

답변 0

답변을 작성해보세요.

답변을 기다리고 있는 질문이에요.
첫번째 답변을 남겨보세요!