Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
SicDoRak
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2023_2_WebPromgramming_8
SicDoRak
Commits
21b756aa
Commit
21b756aa
authored
1 year ago
by
Gwangbin
Browse files
Options
Downloads
Patches
Plain Diff
Feat: Add category search, searchresult
parent
bb9aaafb
Branches
develop
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/components/SearchMapByKeyword.js
+118
-80
118 additions, 80 deletions
frontend/src/components/SearchMapByKeyword.js
with
118 additions
and
80 deletions
frontend/src/components/SearchMapByKeyword.js
+
118
−
80
View file @
21b756aa
...
@@ -7,6 +7,7 @@ function SearchMapByKeyword({loc, setLoc}){
...
@@ -7,6 +7,7 @@ function SearchMapByKeyword({loc, setLoc}){
// 아주대학교를 기본 위치로 설정
// 아주대학교를 기본 위치로 설정
const
[
info
,
setInfo
]
=
useState
()
const
[
info
,
setInfo
]
=
useState
()
const
[
markers
,
setMarkers
]
=
useState
([])
const
[
markers
,
setMarkers
]
=
useState
([])
const
[
pagination
,
setPagination
]
=
useState
()
const
[
map
,
setMap
]
=
useState
()
const
[
map
,
setMap
]
=
useState
()
const
[
searchKeyword
,
setSearchKeyword
]
=
useState
();
//주소 입력
const
[
searchKeyword
,
setSearchKeyword
]
=
useState
();
//주소 입력
...
@@ -25,6 +26,8 @@ function SearchMapByKeyword({loc, setLoc}){
...
@@ -25,6 +26,8 @@ function SearchMapByKeyword({loc, setLoc}){
const
bounds
=
new
kakao
.
maps
.
LatLngBounds
()
const
bounds
=
new
kakao
.
maps
.
LatLngBounds
()
let
markers
=
[]
let
markers
=
[]
setPagination
(
_pagination
);
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
data
.
length
;
i
++
)
{
// @ts-ignore
// @ts-ignore
markers
.
push
({
markers
.
push
({
...
@@ -41,9 +44,18 @@ function SearchMapByKeyword({loc, setLoc}){
...
@@ -41,9 +44,18 @@ function SearchMapByKeyword({loc, setLoc}){
setMarkers
(
markers
)
setMarkers
(
markers
)
// 검색된 장소 위치를 기준으로 지도 범위를 재설정합니다
// 검색된 장소 위치를 기준으로 지도 범위를 재설정합니다
//
map.setBounds(bounds)
map
.
setBounds
(
bounds
)
}
}
})
},
{
category_group_code
:
'
FD6
'
})
}
const
displayPagination
=
(
pagination
)
=>
{
const
links
=
[];
for
(
let
i
=
1
;
i
<=
pagination
.
last
;
i
++
)
{
links
.
push
(
<
a
href
=
"
#
"
onClick
=
{()
=>
pagination
.
gotoPage
(
i
)}
>
{
i
}
<
/a>
)
;
}
return
links
;
}
}
return
(
return
(
...
@@ -53,19 +65,21 @@ function SearchMapByKeyword({loc, setLoc}){
...
@@ -53,19 +65,21 @@ function SearchMapByKeyword({loc, setLoc}){
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
장소 키워드
"
value
=
{
loc
.
keyword
}
/
>
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
장소 키워드
"
value
=
{
loc
.
keyword
}
/
>
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
위도
"
value
=
{
loc
.
center
.
lat
}
/
>
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
위도
"
value
=
{
loc
.
center
.
lat
}
/
>
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
경도
"
value
=
{
loc
.
center
.
lng
}
/
>
<
input
readOnly
=
{
true
}
type
=
"
text
"
placeholder
=
"
경도
"
value
=
{
loc
.
center
.
lng
}
/
>
<
div
style
=
{{
display
:
'
flex
'
}}
>
<
Map
// 지도를 표시할 Container
<
Map
// 지도를 표시할 Container
center
=
{
markers
[
0
]
&&
markers
[
0
]
.
position
||
defaultCenter
}
center
=
{
info
&&
info
.
position
||
defaultCenter
}
style
=
{{
style
=
{{
// 지도의 크기
// 지도의 크기
width
:
"
450px
"
,
width
:
"
450px
"
,
height
:
"
450px
"
height
:
"
450px
"
}}
}}
onCreate
=
{
setMap
}
isPanto
=
{
true
}
level
=
{
3
}
>
level
=
{
3
}
>
{
markers
.
map
((
marker
)
=>
(
{
markers
.
map
((
marker
)
=>
(
<
MapMarker
<
MapMarker
key
=
{
`marker-
${
marker
.
content
}
-
${
marker
.
position
.
lat
}
,
${
marker
.
position
.
lng
}
`
}
key
=
{
`marker-
${
marker
.
content
}
-
${
marker
.
position
.
lat
}
,
${
marker
.
position
.
lng
}
`
}
position
=
{
marker
.
position
}
position
=
{
marker
.
position
}
clickable
=
{
true
}
// 마커를 클릭했을 때 지도의 클릭 이벤트가 발생하지 않도록 설정합니다
clickable
=
{
true
}
// 마커를 클릭했을 때 지도의 클릭 이벤트가 발생하지 않도록 설정합니다
// 마커에 마우스오버 이벤트를 등록합니다
// 마커에 마우스오버 이벤트를 등록합니다
onMouseOver
=
{
onMouseOver
=
{
...
@@ -75,20 +89,44 @@ function SearchMapByKeyword({loc, setLoc}){
...
@@ -75,20 +89,44 @@ function SearchMapByKeyword({loc, setLoc}){
// 마커에 마우스아웃 이벤트를 등록합니다
// 마커에 마우스아웃 이벤트를 등록합니다
onMouseOut
=
{
onMouseOut
=
{
// 마커에 마우스아웃 이벤트가 발생하면 인포윈도우를 제거합니다
// 마커에 마우스아웃 이벤트가 발생하면 인포윈도우를 제거합니다
()
=>
setInfo
(
null
)
()
=>
setInfo
(
{
position
:
marker
.
position
}
)
}
}
onClick
=
{()
=>
{
onClick
=
{()
=>
{
setLoc
({
setLoc
({
keyword
:
marker
.
content
,
keyword
:
marker
.
content
,
center
:
{
lat
:
marker
.
position
.
lat
,
lng
:
marker
.
position
.
lng
}
center
:
{
lat
:
marker
.
position
.
lat
,
lng
:
marker
.
position
.
lng
}
})
})
;
}}
>
}}
>
{
info
&&
info
.
content
===
marker
.
content
&&
(
{
info
&&
info
.
content
===
marker
.
content
&&
(
<
div
style
=
{{
color
:
"
#000
"
}}
>
{
marker
.
content
}
<
/div
>
<
div
style
=
{{
width
:
"
100%
"
,
color
:
"
#000
"
}}
>
{
marker
.
content
}
<
/div
>
)}
)}
<
/MapMarker
>
<
/MapMarker
>
))}
))}
<
/Map
>
<
/Map
>
<
div
>
<
ul
>
{
markers
.
map
((
marker
)
=>
(
<
li
key
=
{
`marker-
${
marker
.
content
}
-
${
marker
.
position
.
lat
}
,
${
marker
.
position
.
lng
}
`
}
onMouseOver
=
{()
=>
{
setInfo
(
marker
)}}
onMouseOut
=
{()
=>
{
setInfo
({
position
:
marker
.
position
})}}
>
<
a
href
=
"
#
"
style
=
{{
textDecoration
:
"
none
"
,
color
:
"
black
"
}}
onClick
=
{()
=>
{
setLoc
({
keyword
:
marker
.
content
,
center
:
{
lat
:
marker
.
position
.
lat
,
lng
:
marker
.
position
.
lng
}
})
}}
>
{
marker
.
content
}
<
/a
>
<
/li
>
))}
<
/ul
>
<
div
style
=
{{
display
:
"
flex
"
,
justifyContent
:
"
center
"
}}
>
{
pagination
&&
displayPagination
(
pagination
)
}
<
/div
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment