Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김서연
/
Corona_Vaccination_Medical_Institution
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
3
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Heo
2021-05-23 02:51:43 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
456ffe04f8f81d6009cf803f81f9d52735e4f3bb
456ffe04
1 parent
69d2c497
인포윈도우 형식 및 정보 수정/맵중싱 이동 수정
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
15 deletions
views/index.ejs
views/index.ejs
View file @
456ffe0
...
...
@@ -17,6 +17,7 @@
<div
id=
"map"
style=
"width:700px;height:400px;"
></div>
<script
type=
"text/javascript"
src=
"https://dapi.kakao.com/v2/maps/sdk.js?appkey=35fccf4b4e2a3179187346f26ed3f988&libraries=services"
></script>
<
% if(typeof(result) != "undefined"){ %>
<script>
var
mapContainer
=
document
.
getElementById
(
'map'
),
// 지도를 표시할 div
...
...
@@ -35,11 +36,8 @@
listData
=
listData
.
replaceAll
(
'"'
,
'\"'
);
listData
=
JSON
.
parse
(
listData
);
// var x = 0;
// var y = 0;
// var count = 0;
var
count
=
0
;
// console.log(listData[1]);
//입력되는 배열명이 listData로 들어오면 됨.
listData
.
forEach
(
function
(
addr
,
index
)
{
var
tmpaddr
=
((
addr
.
orgZipaddr
).
split
(
','
))[
0
];
...
...
@@ -48,9 +46,7 @@
geocoder
.
addressSearch
(
tmpaddr
,
function
(
result
,
status
)
{
if
(
status
===
kakao
.
maps
.
services
.
Status
.
OK
)
{
var
coords
=
new
kakao
.
maps
.
LatLng
(
result
[
0
].
y
,
result
[
0
].
x
);
// y += result[0].y;
// x += result[0].x;
// count += 1;
count
+=
1
;
var
marker
=
new
kakao
.
maps
.
Marker
({
position
:
coords
,
clickable
:
true
});
...
...
@@ -60,20 +56,21 @@
// 인포윈도우를 생성합니다
var
infowindow
=
new
kakao
.
maps
.
InfoWindow
({
content
:
'<div style="width:150px;text-align:center;padding:6px 0;">'
+
addr
[
1
]
+
'</div>'
,
removable
:
true
});
// 마커에 클릭이벤트를 등록합니다
kakao
.
maps
.
event
.
addListener
(
marker
,
'click'
,
function
()
{
// 마커 위에 인포윈도우를 표시합니다
infowindow
.
open
(
map
,
marker
);
content
:
'<div style="width:150px;text-align:center;padding:6px 0;">'
+
'기관명:'
+
addr
.
orgnm
+
'</div>'
,
});
// 마커에 mouseover 이벤트와 mouseout 이벤트를 등록합니다
// 이벤트 리스너로는 클로저를 만들어 등록합니다
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseover'
,
makeOverListener
(
map
,
marker
,
infowindow
));
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseout'
,
makeOutListener
(
infowindow
));
if
(
count
==
1
){
map
.
setCenter
(
coords
);
}
// 지도의 중심을 결과값으로 받은 위치로 이동시킵니다
map
.
setCenter
(
coords
);
//console.log(listData.length);
}
});
});
// 인포윈도우를 표시하는 클로저를 만드는 함수입니다
function
makeOverListener
(
map
,
marker
,
infowindow
)
{
return
function
()
{
...
...
Please
register
or
login
to post a comment