forked from SanE-Seo/SaneE-SEo-Front
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 카카오맵 연동 및 지역 행정구동 검색 기능 구현 (SanE-Seo#21)
- Loading branch information
Showing
7 changed files
with
3,490 additions
and
10 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import * as P from '../../styles/place-search-modal.style'; | ||
import SeoulCoordinates from '../../seoul_districts_coordinates.json'; | ||
type PlaceProps = { | ||
placeInput: string; | ||
setPlaceInput: (value: string) => void; | ||
setIsOpen: (value: boolean) => void; | ||
setLat: (value: number) => void; | ||
setLong: (value: number) => void; | ||
}; | ||
|
||
type DistrictCoordinates = { | ||
[key: string]: { lat: number; lng: number }; | ||
}; | ||
function PlaceSearchModal({ | ||
placeInput, | ||
setPlaceInput, | ||
setIsOpen, | ||
setLat, | ||
setLong, | ||
}: PlaceProps) { | ||
console.log(placeInput); | ||
const [searchResults, setSearchResults] = useState<string[]>([]); | ||
|
||
const coordinates: DistrictCoordinates = SeoulCoordinates; | ||
useEffect(() => { | ||
const results: string[] = []; | ||
for (const districtName in coordinates) { | ||
if (districtName.includes(placeInput)) { | ||
results.push(districtName); | ||
} | ||
} | ||
setSearchResults(results); | ||
}); | ||
return ( | ||
<> | ||
{searchResults.length > 0 && ( | ||
<P.ModalWrapper> | ||
<ul> | ||
{searchResults.map((district, index) => ( | ||
<> | ||
<li | ||
key={index} | ||
className="text-style" | ||
onClick={() => { | ||
setPlaceInput(district); | ||
setLat(coordinates[district].lat); | ||
setLong(coordinates[district].lng); | ||
setIsOpen(false); | ||
}} | ||
> | ||
{district} | ||
</li> | ||
<hr className="line" /> | ||
</> | ||
))} | ||
</ul> | ||
</P.ModalWrapper> | ||
)} | ||
</> | ||
); | ||
} | ||
|
||
export default PlaceSearchModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import useKakaoLoader from '../useKakaoLoader'; | ||
import { Map, Polyline, CustomOverlayMap } from 'react-kakao-maps-sdk'; | ||
|
||
import * as U from '../../styles/user-trail-map.style'; | ||
type MapProps = { | ||
lat: number; | ||
long: number; | ||
}; | ||
function UserTrailMap({ lat, long }: MapProps) { | ||
useKakaoLoader(); | ||
|
||
return ( | ||
<U.MapLayout> | ||
<Map | ||
id="map" | ||
center={{ lat: lat, lng: long }} | ||
className="map-style" | ||
level={2} | ||
></Map> | ||
</U.MapLayout> | ||
); | ||
} | ||
|
||
export default UserTrailMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.