1 parent e72fd61 commit a4ed4b8Copy full SHA for a4ed4b8
1 file changed
src/app/floorplan/page.tsx
@@ -2,12 +2,12 @@
2
import React, { useEffect, useState } from "react";
3
4
export default function Page() {
5
- const [position, setPosition] = useState<GeolocationPosition>();
+ const [positions, setPositions] = useState<GeolocationPosition[]>([]);
6
7
useEffect(() => {
8
const watchID = navigator.geolocation.watchPosition(
9
(position) => {
10
- setPosition(position);
+ setPositions([...positions, position]);
11
},
12
() => { },
13
{ enableHighAccuracy: true, timeout: 5000, maximumAge: 0 }
@@ -16,9 +16,9 @@ export default function Page() {
16
return () => {
17
navigator.geolocation.clearWatch(watchID);
18
}
19
- }, [setPosition]);
+ }, [setPositions]);
20
21
return (<div>
22
- {JSON.stringify(position)}
+ {JSON.stringify(positions)}
23
</div>);
24
0 commit comments