-
Notifications
You must be signed in to change notification settings - Fork 33
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
3 changed files
with
84 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Map } from "react-kakao-maps-sdk" | ||
import useKakaoLoader from "./useKakaoLoader" | ||
import { useState } from "react" | ||
|
||
export default function AddMapBoundsChangedEvent() { | ||
useKakaoLoader() | ||
const [bounds, setBounds] = useState<{ | ||
sw: string | ||
ne: string | ||
}>() | ||
|
||
return ( | ||
<> | ||
<Map // 지도를 표시할 Container | ||
id="map" | ||
center={{ | ||
// 지도의 중심좌표 | ||
lat: 33.450701, | ||
lng: 126.570667, | ||
}} | ||
style={{ | ||
width: "100%", | ||
height: "350px", | ||
}} | ||
level={3} // 지도의 확대 레벨 | ||
onBoundsChanged={(map) => { | ||
const bounds = map.getBounds() | ||
setBounds({ | ||
sw: bounds.getSouthWest().toString(), | ||
ne: bounds.getNorthEast().toString(), | ||
}) | ||
}} | ||
/> | ||
<p> | ||
<em>지도 영역이 변경되면 지도 정보가 표출됩니다</em> | ||
</p> | ||
<p id="result"> | ||
{bounds && ( | ||
<p> | ||
영역좌표는 남서쪽 위도, 경도는 {bounds.sw}이고 <br /> | ||
북동쪽 위도, 경도는 {bounds.ne}입니다{" "} | ||
</p> | ||
)} | ||
</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
34 changes: 34 additions & 0 deletions
34
packages/react-kakao-maps-sdk/__test__/addMapBoundsChangedEvent.spec.ts
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,34 @@ | ||
import { test, expect } from "@playwright/test" | ||
import { getTestUrl, waitNetworkIdleWithTimeout } from "./util" | ||
|
||
test("ScreenShot 렌더링 결과 비교", async ({ page }, testInfo) => { | ||
const url = getTestUrl( | ||
"addMapBoundsChangedEvent", | ||
testInfo.config.updateSnapshots === "all", | ||
) | ||
await page.goto(url, { waitUntil: "networkidle" }) | ||
await waitNetworkIdleWithTimeout(page) | ||
await expect(page).toHaveScreenshot() | ||
|
||
const mapBoundingBox = await page.locator("#map").boundingBox() | ||
await page.mouse.move(mapBoundingBox!.x, mapBoundingBox!.y) | ||
await page.mouse.down() | ||
await page.mouse.move( | ||
mapBoundingBox!.x + mapBoundingBox!.width / 2, | ||
mapBoundingBox!.y + mapBoundingBox!.height / 2, | ||
) | ||
await waitNetworkIdleWithTimeout(page) | ||
|
||
await expect(page.locator("#result")).toHaveText( | ||
"영역좌표는 남서쪽 위도, 경도는 (33.45065294391403, 126.55706658514791)이고 북동쪽 위도, 경도는 (33.45385631221043, 126.57064566190085)입니다 ", | ||
) | ||
await page.mouse.move( | ||
mapBoundingBox!.x + mapBoundingBox!.width / 3, | ||
mapBoundingBox!.y + mapBoundingBox!.height / 3, | ||
) | ||
await page.mouse.up() | ||
await waitNetworkIdleWithTimeout(page) | ||
await expect(page.locator("#result")).toHaveText( | ||
"영역좌표는 남서쪽 위도, 경도는 (33.45012909463751, 126.55933862932383)이고 북동쪽 위도, 경도는 (33.45333221438989, 126.57291771102653)입니다 ", | ||
) | ||
}) |