Skip to content

Commit e72fd61

Browse files
committed
geolocation test
1 parent 6ea9ba9 commit e72fd61

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/app/floorplan/page.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"use client";
2+
import React, { useEffect, useState } from "react";
3+
4+
export default function Page() {
5+
const [position, setPosition] = useState<GeolocationPosition>();
6+
7+
useEffect(() => {
8+
const watchID = navigator.geolocation.watchPosition(
9+
(position) => {
10+
setPosition(position);
11+
},
12+
() => { },
13+
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }
14+
);
15+
16+
return () => {
17+
navigator.geolocation.clearWatch(watchID);
18+
}
19+
}, [setPosition]);
20+
21+
return (<div>
22+
{JSON.stringify(position)}
23+
</div>);
24+
}

0 commit comments

Comments
 (0)