@@ -91,6 +91,7 @@ const Map = ({
91
91
const terrain3DExaggeration = useSelector ( getTerrain3DExaggeration ) ;
92
92
const { viewport, mapSearchMarker, mapStyle, showOSM, layersSettings } = useSelector ( getMap ) ;
93
93
const mapRef = useRef < MapRef | null > ( null ) ;
94
+ const mapContainer = useMemo ( ( ) => mapRef . current ?. getContainer ( ) , [ mapRef . current ] ) ;
94
95
95
96
const pathGeometry = useMemo (
96
97
( ) => geometry || pathProperties ?. geometry ,
@@ -99,15 +100,14 @@ const Map = ({
99
100
100
101
const mapViewport = useMemo ( ( ) => {
101
102
if ( isReadOnly && pathGeometry ) {
102
- const mapContainer = mapRef . current ?. getContainer ( ) ;
103
103
return computeBBoxViewport ( bbox ( pathGeometry ) , viewport , {
104
104
width : mapContainer ?. clientWidth ,
105
105
height : mapContainer ?. clientHeight ,
106
106
padding : 60 ,
107
107
} ) ;
108
108
}
109
109
return viewport ;
110
- } , [ isReadOnly , pathGeometry , viewport , mapRef ] ) ;
110
+ } , [ isReadOnly , pathGeometry , viewport , mapContainer ] ) ;
111
111
112
112
const [ mapIsLoaded , setMapIsLoaded ] = useState ( false ) ;
113
113
@@ -219,15 +219,14 @@ const Map = ({
219
219
type : 'LineString' ,
220
220
} ;
221
221
if ( points . coordinates . length > 2 ) {
222
- const mapContainer = mapRef . current ?. getContainer ( ) ;
223
222
const newViewport = computeBBoxViewport ( bbox ( points ) , mapViewport , {
224
223
width : mapContainer ?. clientWidth ,
225
224
height : mapContainer ?. clientHeight ,
226
225
padding : 60 ,
227
226
} ) ;
228
227
dispatch ( updateViewport ( newViewport ) ) ;
229
228
}
230
- } , [ pathGeometry , simulationPathSteps , mapRef ] ) ;
229
+ } , [ pathGeometry , simulationPathSteps , mapContainer ] ) ;
231
230
232
231
return (
233
232
< >
0 commit comments