-
카테고리
-
세부 분야
풀스택
-
해결 여부
미해결
화면에 지도가 뜨지 않는 이유를 모르겠습니다!
21.02.12 21:43 작성 조회수 115
1
6분 10초까지 따라했는데
새로 고침을 했지만 아예 지도가 표시가 되지 않습니다.
완전 똑같이 따라썼는데 문제가 무엇인지 모르겠습니다!
저번시간까지는 됐습니다
<!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>my first map</title>
<link rel="stylesheet" href="/stylesheets/style.css"/>
<script type="text/javascript" src="https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=zethc2gz24"></script>
</head>
<body>
<div id="navbar">myfirstmap</div>
<div id="infoBox">
<div id="infoTitle">현재 날짜</div>
<div id="infoContent">2020.01.01 </div>
</div>
<div id="map" style="width:100%;height:100vh;"></div>
<!-- 외부 데이터 파일을 가져옴 -->
<script type ="text/javascript" src="/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);
//마커
var markerList =[];
var infowindowList =[];
for (var i in data){
var target = data[i];
var latlng = new naver.maps.LatLng(target.lat , target.lng);
marker = new naver.maps.Marker({
map : map,
position: latlng,
icon : {
content: "<div class ='marker'></div>",
anchor: new naver.maps.Point(12,12) //마커의 중심 설정
},
});
//string 값으로 나온다. `` 백틱
var content = `<div class='infowindow_wrap'>
<div class='infowindow_title'>${target.title}</div>
<div class='infowindow_content'>${target.content}</div>
<div class='infowindow_date'>${target.date}</div>
</div>`
var infowindow = new naver.maps.InfoWindow({
content = content,
backgroundColor: "#00ff0000",
borderColor: "#00ff0000",
anchorSize : new naver.maps.Size(0,0)
//말풍선 형태로 하는 건데 말풍선안나오게 하는 것
})
markerList.push(marker);
infowindowList.push(infowindow);
}
for(var i=0, ii=markerList.length; i<ii; i++){
naver.maps.Event.addListener(markerList[i],"click", getClickHandler(i));
}
function getClickHandler(i){
return function(){
var marker = markerList[i];
var infowindow = infowindowList[i];
//infowindow가 지금 지도에 표시 되어있는지
if(infowindow.getMap()){
infowindow.close();
}
else{
infowindow.open(map.marker)
}
}
}
</script>
</body>
</html>
답변을 작성해보세요.
0
답변 1