-
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
4 changed files
with
74 additions
and
30 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,36 @@ | ||
import { Map } from "react-kakao-maps-sdk" | ||
import useKakaoLoader from "./useKakaoLoader" | ||
import { useState } from "react" | ||
|
||
export default function AddMapClickEvent() { | ||
useKakaoLoader() | ||
const [result, setResult] = useState("") | ||
|
||
return ( | ||
<> | ||
<Map // 지도를 표시할 Container | ||
id="map" | ||
center={{ | ||
// 지도의 중심좌표 | ||
lat: 33.450701, | ||
lng: 126.570667, | ||
}} | ||
style={{ | ||
width: "100%", | ||
height: "350px", | ||
}} | ||
level={3} // 지도의 확대 레벨 | ||
onClick={(_, mouseEvent) => { | ||
const latlng = mouseEvent.latLng | ||
setResult( | ||
`클릭한 위치의 위도는 ${latlng.getLat()} 이고, 경도는 ${latlng.getLng()} 입니다`, | ||
) | ||
}} | ||
/> | ||
<p> | ||
<em>지도를 클릭해주세요!</em> | ||
</p> | ||
<p id="result">{result}</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
30 changes: 30 additions & 0 deletions
30
packages/react-kakao-maps-sdk/__test__/addMapClickEvent.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,30 @@ | ||
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( | ||
"addMapClickEvent", | ||
testInfo.config.updateSnapshots === "all", | ||
) | ||
await page.goto(url, { waitUntil: "networkidle" }) | ||
await page.waitForLoadState("networkidle") | ||
await expect(page).toHaveScreenshot() | ||
|
||
const mapBoundingBox = await page.locator("#map").boundingBox() | ||
await page.mouse.click(mapBoundingBox!.x, mapBoundingBox!.y) | ||
await expect(page.locator("#result")).toHaveText( | ||
"클릭한 위치의 위도는 33.452254813152855 이고, 경도는 126.5638559967347 입니다", | ||
) | ||
|
||
await page.mouse.click( | ||
mapBoundingBox!.x + mapBoundingBox!.width / 2, | ||
mapBoundingBox!.y + mapBoundingBox!.height / 2, | ||
) | ||
await expect(page.locator("#result")).toHaveText( | ||
"클릭한 위치의 위도는 33.450700761312206 이고, 경도는 126.57066121198349 입니다", | ||
) | ||
}) |