Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김민규
/
rest_stop_list
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
지창언
2022-05-27 17:46:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
556f319ca8d86ebfd3880919281f957b7a5b270c
556f319c
1 parent
fdd287fa
map api infowindow updated
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
87 deletions
app/views/index.html
app/views/index.html
View file @
556f319
...
...
@@ -15,7 +15,18 @@
<script
type=
"text/javascript"
src=
"//dapi.kakao.com/v2/maps/sdk.js?appkey=c71c02e15245260c3350614980ba87c8&libraries=services,clusterer,drawing"
></script>
<script
src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"
></script>
<script>
function
makeOverListener
(
map
,
marker
,
infowindow
)
{
return
function
()
{
infowindow
.
open
(
map
,
marker
);
};
}
// 인포윈도우를 닫는 클로저를 만드는 함수입니다
function
makeOutListener
(
infowindow
)
{
return
function
()
{
infowindow
.
close
();
};
}
// 고속도로 선택 함수
function
showline
(
lineNumber
){
// 이 위치에 이전에 켜져있는 map을 지우는 기능 넣어야해 ...
...
...
@@ -54,13 +65,14 @@
polyline
.
setMap
(
map
)
var
userData
;
var
markers
=
[];
var
infos
=
[];
var
routeCodes
=
[];
var
svarAddrs
=
[];
var
rest_names
=
[];
// 1번 페이지
$
.
ajax
({
url
:
"http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=1"
,
async
:
false
,
success
:
function
(
data
){
...
...
@@ -68,8 +80,6 @@
userData
=
data
;
},
}).
done
(
function
()
{
var
infomations
=
[];
var
result_str
=
""
;
var
routeCode
=
""
;
var
svarAddr
=
""
;
var
rest_name
=
""
;
...
...
@@ -82,131 +92,123 @@
if
(
routeCode
.
substring
(
1
,
5
)
===
lineNumber
){
// 고속도로 코드가 같다면
routeCodes
.
push
(
routeCode
);
svarAddrs
.
push
(
svarAddr
);
rest_names
.
push
(
rest_name
);
var
geocoder
=
new
kakao
.
maps
.
services
.
Geocoder
();
// 주소로 좌표를 검색합니다
geocoder
.
addressSearch
(
svarAddr
,
function
(
result
,
status
)
{
// 정상적으로 검색이 완료됐으면
if
(
status
===
kakao
.
maps
.
services
.
Status
.
OK
)
{
//위치 저장
var
coords
=
new
kakao
.
maps
.
LatLng
(
result
[
0
].
y
,
result
[
0
].
x
);
var
marker
=
new
kakao
.
maps
.
Marker
({
position
:
coords
,
map
:
map
});
markers
.
push
(
marker
);
// markers 로 정상적 push 수행 안됨
}
});
}
}
svarAddrs
.
forEach
(
function
(
addr
,
index
){
geocoder
.
addressSearch
(
addr
,
function
(
result
,
status
){
if
(
status
===
kakao
.
maps
.
services
.
Status
.
OK
){
var
coords
=
new
kakao
.
maps
.
LatLng
(
result
[
0
].
y
,
result
[
0
].
x
);
var
marker
=
new
kakao
.
maps
.
Marker
({
position
:
coords
,
map
:
map
,
})
setTimeout
(()
=>
{
alert
(
markers
.
length
);
console
.
dir
(
markers
);
},
500
);
var
infowindow
=
new
kakao
.
maps
.
InfoWindow
({
content
:
rest_names
[
index
],
});
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseover'
,
makeOverListener
(
map
,
marker
,
infowindow
));
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseout'
,
makeOutListener
(
infowindow
));
}
})
})
})
/*
// 2번 페이지
$
.
ajax
({
url
:
"http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=2"
,
async
:
false
,
success
:
function
(
data
){
var userData = JSON.stringify(data);
var result_str="";
//변수 설정
userData
=
data
;
},
}).
done
(
function
()
{
var
routeCode
=
""
;
var
svarAddr
=
""
;
var
rest_name
=
""
;
var count = data["list"].length;
var
data_count
=
userData
[
"list"
].
length
// 데이터 개수 얻기
for (var i =0; i<count; i++){
routeCode = JSON.stringify(data["list"][i]["routeCode"]);
svarAddr = JSON.stringify(data["list"][i]["svarAddr"]);
rest_name = JSON.stringify(data["list"][i]["serviceAreaName"]);
var infowindow = new kakao.maps.InfoWindow({
content: rest_name
});
if(routeCode.substring(1,5) === lineNumber){
document.getElementById("testArea").innerHTML += routeCode.substring(1,5)+ " ";
var geocoder = new kakao.maps.services.Geocoder();
for
(
var
i
=
0
;
i
<
data_count
;
i
++
){
routeCode
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"routeCode"
]);
svarAddr
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"svarAddr"
]);
rest_name
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"serviceAreaName"
]);
// 주소로 좌표를 검색합니다
geocoder.addressSearch(svarAddr, function(result, status) {
if
(
routeCode
.
substring
(
1
,
5
)
===
lineNumber
){
// 고속도로 코드가 같다면
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
routeCodes
.
push
(
routeCode
);
svarAddrs
.
push
(
svarAddr
);
rest_names
.
push
(
rest_name
);
var
geocoder
=
new
kakao
.
maps
.
services
.
Geocoder
();
}
}
svarAddrs
.
forEach
(
function
(
addr
,
index
){
geocoder
.
addressSearch
(
addr
,
function
(
result
,
status
){
if
(
status
===
kakao
.
maps
.
services
.
Status
.
OK
){
var
coords
=
new
kakao
.
maps
.
LatLng
(
result
[
0
].
y
,
result
[
0
].
x
);
var temp = i
// 결과값으로 받은 위치를 마커로 표시합니다
var
marker
=
new
kakao
.
maps
.
Marker
({
map: map,
position: coords,
position
:
coords
,
map
:
map
,
})
var
infowindow
=
new
kakao
.
maps
.
InfoWindow
({
content
:
rest_names
[
index
],
});
// 인포윈도우로 장소에 대한 설명을 표시합니다
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseover'
,
makeOverListener
(
map
,
marker
,
infowindow
));
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseout'
,
makeOutListener
(
infowindow
));
document.getElementById("position_ex").innerHTML = svarAddr;
}
});
}
}
},
})
})
})
// 3번 페이지
$
.
ajax
({
url
:
"http://data.ex.co.kr/openapi/business/conveniServiceArea?key=1817997939&type=json&numOfRows=99&pageNo=3"
,
async
:
false
,
success
:
function
(
data
){
var userData = JSON.stringify(data);
var result_str="";
//변수 설정
userData
=
data
;
},
}).
done
(
function
()
{
var
routeCode
=
""
;
var
svarAddr
=
""
;
var
rest_name
=
""
;
var count = data["list"].length;
var
data_count
=
userData
[
"list"
].
length
// 데이터 개수 얻기
for (var i =0; i<count; i++){
routeCode = JSON.stringify(data["list"][i]["routeCode"]);
svarAddr = JSON.stringify(data["list"][i]["svarAddr"]);
rest_name = JSON.stringify(data["list"][i]["serviceAreaName"]);
var infowindow = new kakao.maps.InfoWindow({
content: rest_name
});
if(routeCode.substring(1,5) === lineNumber){
document.getElementById("testArea").innerHTML += routeCode.substring(1,5)+ " ";
var geocoder = new kakao.maps.services.Geocoder();
for
(
var
i
=
0
;
i
<
data_count
;
i
++
){
routeCode
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"routeCode"
]);
svarAddr
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"svarAddr"
]);
rest_name
=
JSON
.
stringify
(
userData
[
"list"
][
i
][
"serviceAreaName"
]);
// 주소로 좌표를 검색합니다
geocoder.addressSearch(svarAddr, function(result, status) {
if
(
routeCode
.
substring
(
1
,
5
)
===
lineNumber
){
// 고속도로 코드가 같다면
// 정상적으로 검색이 완료됐으면
if (status === kakao.maps.services.Status.OK) {
routeCodes
.
push
(
routeCode
);
svarAddrs
.
push
(
svarAddr
);
rest_names
.
push
(
rest_name
);
var
geocoder
=
new
kakao
.
maps
.
services
.
Geocoder
();
}
}
svarAddrs
.
forEach
(
function
(
addr
,
index
){
geocoder
.
addressSearch
(
addr
,
function
(
result
,
status
){
if
(
status
===
kakao
.
maps
.
services
.
Status
.
OK
){
var
coords
=
new
kakao
.
maps
.
LatLng
(
result
[
0
].
y
,
result
[
0
].
x
);
var temp = i
// 결과값으로 받은 위치를 마커로 표시합니다
var
marker
=
new
kakao
.
maps
.
Marker
({
map: map,
position: coords,
position
:
coords
,
map
:
map
,
})
var
infowindow
=
new
kakao
.
maps
.
InfoWindow
({
content
:
rest_names
[
index
],
});
// 인포윈도우로 장소에 대한 설명을 표시합니다
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseover'
,
makeOverListener
(
map
,
marker
,
infowindow
));
kakao
.
maps
.
event
.
addListener
(
marker
,
'mouseout'
,
makeOutListener
(
infowindow
));
document.getElementById("position_ex").innerHTML = svarAddr;
}
});
}
}
},
})
*/
})
})
}
</script>
</head>
...
...
Please
register
or
login
to post a comment