Places 코드가 안돼요.
351
al3616819
2 asked
0
let ps = new naver.maps.service.Piaces();
Places(); 이부분이 안돼요.
검색 기능이 안되요. ㅠㅠ
도와주세요.
<!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=x8m68jepl8"
></script>
<script
src="https://code.jquery.com/jquery-3.6.0.min.js"
integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4="
crossorigin="anonymous"
></script>
<script
type="text/javascript"
src="//dapi.kakao.com/v2/maps/sdk.js?appkey=08431822c52c7e66355e30a38ecf97bc&libraries=services"
></script>
</head>
<body>
<div id="navbar">myfirstmap</div>
<div id="infoBox">
<div id="infoTitle">현재날짜</div>
<div id="infoConent">2022.08.10</div>
</div>
<div id="search">
<input id="search_input" placeholder="목적지를 입력해주세요" />
<button id="search_button">검색</button>
</div>
<div id="current">현재 위치</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),
},
});
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(map, "click", ClickMap(i));
naver.maps.Event.addListener(
markerList[i],
"click",
getClickHandler(i)
);
}
function ClickMap(i) {
return function () {
var InfoWindow = infowindowList[i];
infowindow.close();
};
}
function getClickHandler(i) {
return function () {
var marker = markerList[i];
var InfoWindow = infowindowList[i];
if (infowindow.getMap()) {
infowindow.close();
} else {
infowindow.open(map, marker);
}
};
}
let currentUse = true;
$("#current").click(() => {
if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(function (position) {
const lat = position.coords.latitude;
const lng = position.coords.longitude;
const latlng = new naver.maps.LatLng(lat, lng);
if (currentUse) {
marker = new naver.maps.Marker({
map: map,
position: latlng,
icon: {
content:
'<img class="pulse" draggable="false" unselectable="on" src="https://myfirstmap.s3.ap-northeast-2.amazonaws.com/circle.png" >',
anchor: new naver.maps.Point(11, 11),
},
});
currentUse = false;
}
map.setZoom(14, false);
map.panTo(latlng);
});
} else {
alert("위치정보 사용 불가능");
}
});
let ps = new kakao.maps.services.Places();
$("#search_input").on("keydown", function (e) {
if (e.keyCode === 13) {
let content = $(this).val();
ps.keywordSearch(content, placeSearchCB);
}
});
function placeSearchCB(data, status, pagination) {
if (status === kakao.maps.services.Status.OK) {
let target = data[0];
const lat = target.y;
const lng = target.x;
const latlng = new naver.maps.LatLng(lat, lng);
marker = new naver.maps.Marker({
position: latlng,
map: map,
});
} else {
alert("검색결과가 없습니다.");
}
}
</script>
</body>
</html>

express
웹앱
vscode
nodejs
Answer 0
map API
0
36
1
nodejs 터미널 인식
0
38
1
kakao is not defined 오류
0
415
1
nodemon ./bin/www 입력 시 오류
0
166
1
호스팅 및 도메인 관련
0
160
1
마커이미지가 깨집니다
0
145
2
nodemon설치와 express-generator 오류
0
222
1
코드를 다운받을수 있나요?
0
204
1
SUDO를 계속 입력하지 않는 방법을 알 수 있을까요?
0
601
1
var로 선언하는 이유
0
368
1
애니메이션 관련 질문
0
271
1
(index):121 Uncaught ReferenceError: kakao is not defined at (index):121:10
0
617
0
히트맵 구성
0
244
0
이벤트리스너 추가부분 질문..
0
298
2
for문 돌릴때 ii 에 대해서 궁금합니다.
1
389
1
express 설정
0
253
0
이름공간 문법?
0
271
0
마커가 안뜹니다
1
318
2
nodemon 설치 에러
0
413
1
AI NAVER API 관련 질문
1
373
2
궁금한게 있어요 link로 연결할때 href에 public 경로를 빼야만 적용되는 이유는 뭔가요??
1
225
0
node와 ncm 의 버전 확인이 안됩니다ㅠㅠ
0
423
1
저장후엔 localhost가 열리지 않네요ㅠ
0
299
0
설치가 안됩니다
0
200
1

