Skip to content

Commit

Permalink
feat: Map 페이지 1차 완성
Browse files Browse the repository at this point in the history
  • Loading branch information
namnam-5799 committed Jan 16, 2023
1 parent e0eedeb commit d89131d
Show file tree
Hide file tree
Showing 7 changed files with 242 additions and 6 deletions.
Binary file modified project/node_modules/.cache/default-development/0.pack
Binary file not shown.
Binary file modified project/node_modules/.cache/default-development/index.pack
Binary file not shown.
4 changes: 2 additions & 2 deletions project/src/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import Login from './components/Login';
import KakaoMap from './components/KakaoMap';

import Map from './pages/Map';
import Post from "./pages/Post";
import PlaceDetail from './pages/PlaceDetail';
import Modal from './components/Modal';
Expand All @@ -28,7 +28,7 @@ function Main() {
return (
<>
<Header>header헤더</Header>
<PlaceDetail></PlaceDetail>
<Map></Map>
<Footer>footer</Footer>
</>
);
Expand Down
6 changes: 3 additions & 3 deletions project/src/components/KakaoMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let info =
</div>`


const KakaoMap = () =>{
const KakaoMap = ({width, height, dataList}:{width:string, height:string, dataList:string[]}) =>{

useEffect(()=>{
const container = document.getElementById('map');// 지도를 담을 dom영역
Expand All @@ -42,7 +42,7 @@ const KakaoMap = () =>{
// 주소 - 좌표 변환
// 주소-좌표 변환 객체를 생성합니다
var geocoder = new window.kakao.maps.services.Geocoder();
listData.forEach(function(addr,index){
dataList.forEach(function(addr,index){
geocoder.addressSearch(addr, function(result:any, status:any) {
// 정상적으로 검색이 완료됐으면
if (status === window.kakao.maps.services.Status.OK) {
Expand All @@ -55,7 +55,7 @@ const KakaoMap = () =>{

// 인포 윈도우 설정
var infowindow = new window.kakao.maps.InfoWindow({
content: '<div style="width:120px;text-align:center;font-size:12px":color:#3300C6>' + listData[index] + '</div>',
content: '<div style="width:120px;text-align:center;font-size:12px":color:#3300C6>' + dataList[index] + '</div>',
disableAutoPan: true
});
infowindow.open(map, marker);
Expand Down
27 changes: 27 additions & 0 deletions project/src/dummyData.json
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,32 @@
"recommend": "212",
"memberId": "1"
}
],
"region":[
{ "id": "0", "post": "강남구"},
{ "id": "1", "post": "강동구"},
{ "id": "2", "post": "강북구"},
{ "id": "3", "post": "강서구"},
{ "id": "4", "post": "관악구"},
{ "id": "5", "post": "광진구"},
{ "id": "6", "post": "구로구"},
{ "id": "7", "post": "금천구"},
{ "id": "8", "post": "노원구"},
{ "id": "9", "post": "도봉구"},
{ "id": "10", "post": "동대문구"},
{ "id": "11", "post": "동작구"},
{ "id": "12", "post": "마포구"},
{ "id": "13", "post": "서대문구"},
{ "id": "14", "post": "서초구"},
{ "id": "15", "post": "성동구"},
{ "id": "16", "post": "성북구"},
{ "id": "17", "post": "송파구"},
{ "id": "18", "post": "양천구"},
{ "id": "19", "post": "영등포구"},
{ "id": "20", "post": "용산구"},
{ "id": "21", "post": "은평구"},
{ "id": "22", "post": "종로구"},
{ "id": "23", "post": "중구"},
{ "id": "24", "post": "중랑구"}
]
}
200 changes: 200 additions & 0 deletions project/src/pages/Map.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
import styled from "styled-components";
import KakaoMap from "../components/KakaoMap";
import dummy from "../dummyData.json";
import { useState, useEffect } from "react";
import { RiArrowDropDownLine} from 'react-icons/ri';
import { FaMapMarkerAlt } from 'react-icons/fa';

// 전체 영역을 감싸는 컴포넌트 입니다.
const Container = styled.div`
display: flex;
`

// 좌측 명소 리스트를 보여주는 컴포넌트 입니다.
const PlaceList = styled.div`
width: 25%;
height: 90vh;
padding: 10px 0;
`

const DropDown = styled.article`
position: absolute;
margin-left: 20px;
>button{
cursor: pointer;
background-color: white;
width: 295px;
height: 40px;
margin-left: 5px;
line-height: 40px;
display: flex;
border: 1px solid var(--black-600);
border-radius: var(--br-s);
>div:nth-child(1){
width: 150px;
height: 40px;
text-align: center;
font-weight: bold;
line-height: 40px;
margin-left: 65px;
}
>div:nth-child(2){
margin-top: 4px;
margin-left:40px;
}
}
`

const SelectList = styled.div`
display: flex;
flex-direction: column;
width: 295px;
height: 200px;
margin-left: 5px;
overflow-y: scroll;
overflow-x: hidden;
color:var(--black-750);
position: relative;
top:0;
border-collapse: collapse;
>button{
cursor: pointer;
font-weight: bold;
background-color: white;
width: 280px;
height: 40px;
padding: 10px 0;
border: 0.5px solid var(--black-500);
:hover{
color: var(--purple-400);
}
}
`

const PlaceComponent = styled.div`
margin-top: 50px;
width: 292px;
height: 84vh;
margin-left: 26px;
background-color: white;
`
const Place = styled.div`
background-color: skyblue;
width: 294px;
height: 140px;
margin-left: -1px;
border-radius: var(--br-s);
cursor: pointer;
border:1px solid var(--black-600);
background: linear-gradient(
to right,
rgba(20, 20, 20, 0.8) 10%,
rgba(20, 20, 20, .7) 25%,
rgba(20, 20, 20, 0.5) 50%,
rgba(20, 20, 20, 0.35) 75%,
rgba(20, 20, 20, 0.25) 100%
), url(https://a.cdn-hotels.com/gdcs/production60/d1151/364e7147-c289-4151-9f1e-070061df4f54.jpg?impolicy=fcrop&w=1600&h=1066&q=medium);
background-size: cover;
>div{
padding:85px 0 0 20px;
font-weight: bold;
font-size: 20px;
color:white;
}
>p{
padding:3px 0 0 20px;
font-weight: bold;
font-size: 12px;
color:white;
}
`

const Map = () => {

// 주소 더미 데이터
var listData = [
'종로구 사직로 161',
'종로구 세종대로 198',
'종로구 세종대로 209',
'종로구 세종대로 175'
];

// 드롭다운 메뉴를 보여줄지 말지 설정하는 변수
const [dropdownView, setDropdownView] = useState(false)
//현재 눌린 버튼의 값 설정
const [regionFilter,setRegionFilter] = useState('강동구')

useEffect(()=>{

},[regionFilter])

let Post = [
{ id: "1", Post: "강남구" },
{ id: "2", Post: "강동구" },
{ id: "3", Post: "강북구" },
{ id: "4", Post: "강서구" },
{ id: "5", Post: "관악구" },
{ id: "6", Post: "광진구" },
{ id: "7", Post: "구로구" },
{ id: "8", Post: "금천구" },
{ id: "9", Post: "노원구" },
{ id: "10", Post: "도봉구" },
{ id: "11", Post: "동대문구" },
{ id: "12", Post: "동작구" },
{ id: "13", Post: "마포구" },
{ id: "14", Post: "서대문구" },
{ id: "15", Post: "서초구" },
{ id: "16", Post: "성동구" },
{ id: "17", Post: "성북구" },
{ id: "18", Post: "성송파구" },
{ id: "19", Post: "양천구" },
{ id: "20", Post: "영등포구" },
{ id: "21", Post: "용산구" },
{ id: "22", Post: "은평구" },
{ id: "23", Post: "종로구" },
{ id: "24", Post: "중구" },
{ id: "25", Post: "중량구" },
];


const url:string = "https://a.cdn-hotels.com/gdcs/production60/d1151/364e7147-c289-4151-9f1e-070061df4f54.jpg?impolicy=fcrop&w=1600&h=1066&q=medium"

return(
<>
<Container>
<PlaceList>
<DropDown>
<button
onClick={()=>{setDropdownView(!dropdownView)}}>
<div>{regionFilter}</div>
<div><RiArrowDropDownLine size="30" color= "#6255F8"></RiArrowDropDownLine></div>
</button>
{ dropdownView ?
<SelectList>
{
Post.map((el:any, index:number)=>{
return(
<button key={index} onClick={()=>{setRegionFilter(el.Post);setDropdownView(false)}}>{el.Post}</button>
)
})
}
</SelectList>
: null }
</DropDown>
<PlaceComponent>
<Place onClick={()=>{alert('테스트')}}>
<div>종로</div>
<p><FaMapMarkerAlt size="10"></FaMapMarkerAlt> 서울 종로구 세종로</p>
</Place>
</PlaceComponent>
</PlaceList>
<KakaoMap width="50%" height="90vh" dataList={listData}></KakaoMap>
</Container>
</>
)
}

export default Map;
11 changes: 10 additions & 1 deletion project/src/pages/PlaceDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,15 @@ const PlaceDetail = ():JSX.Element => {
const [shareOpen, setShareOpen] = useState(false);
const [fixBar, setFixBar] = useState(0);


// 주소 더미 데이터
var listData = [
'종로구 사직로 161',
'종로구 세종대로 198',
'종로구 세종대로 209',
'종로구 세종대로 175'
];

function onScroll() {
if(window.scrollY <= 700){
setTimeout(function() {
Expand Down Expand Up @@ -258,7 +267,7 @@ const PlaceDetail = ():JSX.Element => {
<div><FaMapMarkerAlt color="grey" size="19"></FaMapMarkerAlt></div>
<p>종로구 사직로 161</p>
</div>
<KakaoMap></KakaoMap>
<KakaoMap width="840px" height="400px" dataList={listData}></KakaoMap>
</Container>
<Post ref={scrollRefContent}>
<PostHeader>
Expand Down

0 comments on commit d89131d

Please sign in to comment.