Skip to content

Commit a0b01ce

Browse files
committed
sarah's review
1 parent 6a1de18 commit a0b01ce

File tree

1 file changed

+3
-4
lines changed
  • front/src/modules/trainschedule/components/ManageTrainSchedule

1 file changed

+3
-4
lines changed

front/src/modules/trainschedule/components/ManageTrainSchedule/Map.tsx

+3-4
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ const Map = ({
9191
const terrain3DExaggeration = useSelector(getTerrain3DExaggeration);
9292
const { viewport, mapSearchMarker, mapStyle, showOSM, layersSettings } = useSelector(getMap);
9393
const mapRef = useRef<MapRef | null>(null);
94+
const mapContainer = useMemo(() => mapRef.current?.getContainer(), [mapRef.current]);
9495

9596
const pathGeometry = useMemo(
9697
() => geometry || pathProperties?.geometry,
@@ -99,15 +100,14 @@ const Map = ({
99100

100101
const mapViewport = useMemo(() => {
101102
if (isReadOnly && pathGeometry) {
102-
const mapContainer = mapRef.current?.getContainer();
103103
return computeBBoxViewport(bbox(pathGeometry), viewport, {
104104
width: mapContainer?.clientWidth,
105105
height: mapContainer?.clientHeight,
106106
padding: 60,
107107
});
108108
}
109109
return viewport;
110-
}, [isReadOnly, pathGeometry, viewport, mapRef]);
110+
}, [isReadOnly, pathGeometry, viewport, mapContainer]);
111111

112112
const [mapIsLoaded, setMapIsLoaded] = useState(false);
113113

@@ -219,15 +219,14 @@ const Map = ({
219219
type: 'LineString',
220220
};
221221
if (points.coordinates.length > 2) {
222-
const mapContainer = mapRef.current?.getContainer();
223222
const newViewport = computeBBoxViewport(bbox(points), mapViewport, {
224223
width: mapContainer?.clientWidth,
225224
height: mapContainer?.clientHeight,
226225
padding: 60,
227226
});
228227
dispatch(updateViewport(newViewport));
229228
}
230-
}, [pathGeometry, simulationPathSteps, mapRef]);
229+
}, [pathGeometry, simulationPathSteps, mapContainer]);
231230

232231
return (
233232
<>

0 commit comments

Comments
 (0)