<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kakao Maps API</title>
<!-- Kakao Map API -->
<script type="text/javascript" src="https://dapi.kakao.com/v2/maps/sdk.js?appkey=javascriptAPI"></script>
</head>
<body>
<div id="map"></div>
<div id="clickLatlng"></div>
<script>
var container = document.getElementById('map'); //DOM reference of the area to contain the map
var options = { //Basic options required when creating a map
center: new kakao.maps.LatLng(33.450701, 126.570667), //Center coordinates of the map.
level: 3 //Level of the map (degree of zoom in/out)
// disableClickZoom: true // Sets the map not to zoom when clicking on the cluster marker.
};
var map = new kakao.maps.Map(container, options); // Create map and return object
// This is where the marker will be displayed
var markerPosition = new kakao.maps.LatLng(33.450701, 126.570667);
// create a marker
var marker = new kakao.maps.Marker({
position: markerPosition
});
// Set the marker to appear on the map
marker.setMap(map);
// The code below removes the marker on the map.
// marker.setMap(null);
// Register a click event on the map
// When you click on the map, the function passed as the last parameter is called.
kakao.maps.event.addListener(map, 'click', function(mouseEvent) {
// Get the clicked latitude and longitude information
var latlng = mouseEvent. latLng;
// Move the marker position to the clicked position
marker.setPosition(latlng);
// Message to display the latitude and longitude of the location clicked with the mouse
var message = 'The latitude of the clicked location is ' + latlng.getLat() + ', ';
message += 'Longitude is ' + latlng.getLng() + '';
// Set the above message to the innerHTML of the <div> tag with the ID value 'clickLatlng'.
var resultDiv = document.getElementById('clickLatlng');
resultDiv.innerHTML = message;
});
</script>
</body>
</html>
크롬 개발자 도구의 콘솔창에 뜬 오류를 확인해 주시기 바랍니다.
추가로 네트워크 탭에서 sdk가 로딩됬는지도 확인해 주시구요.
appkey 이슈일 확률이 큽니다.
아무튼 콘솔창에 뜬 오류를 확인해 주시고 말씀해 주시기 바랍니다.