-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- #61
- Loading branch information
Showing
4 changed files
with
92 additions
and
49 deletions.
There are no files selected for viewing
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
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,68 @@ | ||
import { Map, MapMarker, useMap } from "react-kakao-maps-sdk" | ||
import useKakaoLoader from "./useKakaoLoader" | ||
import { useMemo, useState } from "react" | ||
|
||
export default function SetBounds() { | ||
useKakaoLoader() | ||
const [points] = useState< | ||
{ | ||
lat: number | ||
lng: number | ||
}[] | ||
>([ | ||
{ lat: 33.452278, lng: 126.567803 }, | ||
{ lat: 33.452671, lng: 126.574792 }, | ||
{ lat: 33.451744, lng: 126.572441 }, | ||
]) | ||
|
||
return ( | ||
<> | ||
<Map // 지도를 표시할 Container | ||
id="map" | ||
center={{ | ||
// 지도의 중심좌표 | ||
lat: 33.450701, | ||
lng: 126.570667, | ||
}} | ||
style={{ | ||
// 지도의 크기 | ||
width: "100%", | ||
height: "350px", | ||
}} | ||
level={3} // 지도의 확대 레벨 | ||
> | ||
{points.map((point) => ( | ||
<MapMarker | ||
key={`marker__${point.lat}-${point.lng}`} | ||
position={point} | ||
/> | ||
))} | ||
<ReSetttingMapBounds points={points} /> | ||
</Map> | ||
</> | ||
) | ||
} | ||
|
||
const ReSetttingMapBounds = ({ | ||
points, | ||
}: { | ||
points: { lat: number; lng: number }[] | ||
}) => { | ||
const map = useMap() | ||
const bounds = useMemo(() => { | ||
const bounds = new kakao.maps.LatLngBounds() | ||
|
||
points.forEach((point) => { | ||
bounds.extend(new kakao.maps.LatLng(point.lat, point.lng)) | ||
}) | ||
return bounds | ||
}, [points]) | ||
|
||
return ( | ||
<p> | ||
<button onClick={() => map.setBounds(bounds)}> | ||
지도 범위 재설정 하기 | ||
</button> | ||
</p> | ||
) | ||
} |
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
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,17 @@ | ||
import { test, expect } from "@playwright/test" | ||
|
||
const getUrl = (id: string, isUpdateSanpShots: boolean = false) => | ||
isUpdateSanpShots | ||
? `http://127.0.0.1:5252/samples/${id}.html` | ||
: `/samples/${id}` | ||
|
||
test("ScreenShot 렌더링 결과 비교", async ({ page }, testInfo) => { | ||
const url = getUrl("setBounds", testInfo.config.updateSnapshots === "all") | ||
await page.goto(url, { waitUntil: "networkidle" }) | ||
await page.waitForLoadState("networkidle") | ||
await expect(page).toHaveScreenshot() | ||
|
||
await page.getByText("지도 범위 재설정 하기").click() | ||
await page.waitForLoadState("networkidle") | ||
await expect(page).toHaveScreenshot() | ||
}) |