@@ -12,10 +12,10 @@ function RoutePage() {
12
12
const [ orientation , setOrientation ] = useState ( 0 ) ;
13
13
const [ rotation , setRotation ] = useState ( 0 ) ;
14
14
const [ angle , setAngle ] = useState ( 0 ) ;
15
- const [ latitude , setLatitude ] = useState ( null ) ;
16
- const [ longitude , setLongitude ] = useState ( null ) ;
17
- const [ userLatitude , setUserLatitude ] = useState ( null ) ;
18
- const [ userLongitude , setUserLongitude ] = useState ( null ) ;
15
+ const [ latitude , setLatitude ] = useState ( 0 ) ;
16
+ const [ longitude , setLongitude ] = useState ( 0 ) ;
17
+ const [ userLatitude , setUserLatitude ] = useState ( 0 ) ;
18
+ const [ userLongitude , setUserLongitude ] = useState ( 0 ) ;
19
19
let handlerAvailable = true ;
20
20
let locationHandlerAvailable = true ;
21
21
const isIOS =
@@ -80,6 +80,16 @@ function RoutePage() {
80
80
}
81
81
}
82
82
83
+ useEffect ( ( ) => {
84
+ if ( ! isIOS ) {
85
+ window . addEventListener (
86
+ "deviceorientationabsolute" ,
87
+ deviceOrientationHandler ,
88
+ true
89
+ ) ;
90
+ }
91
+ } , [ ] ) ;
92
+
83
93
useEffect ( ( ) => {
84
94
if ( pointsOfInterest ) {
85
95
setLatitude (
@@ -93,15 +103,7 @@ function RoutePage() {
93
103
] . longitude
94
104
) ;
95
105
}
96
-
97
- if ( ! isIOS ) {
98
- window . addEventListener (
99
- "deviceorientationabsolute" ,
100
- deviceOrientationHandler ,
101
- true
102
- ) ;
103
- }
104
- } , [ ] ) ;
106
+ } , [ pointsOfInterest ] ) ;
105
107
106
108
if ( selectedRoute === null ) return null ;
107
109
return (
0 commit comments