Skip to content

Commit 82d01b4

Browse files
committed
front: adapt map changes after rebase
Signed-off-by: SarahBellaha <sarah.bellaha@sncf.fr>
1 parent fc56f3c commit 82d01b4

File tree

1 file changed

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

1 file changed

+10
-3
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ type MapProps = {
6464
isReadOnly?: boolean;
6565
hideAttribution?: boolean;
6666
hideItinerary?: boolean;
67+
isPathfindingLoading?: boolean;
6768
preventPointSelection?: boolean;
6869
id: string;
6970
simulationPathSteps: MarkerInformation[];
@@ -85,6 +86,7 @@ const NewMap = ({
8586
isReadOnly = false,
8687
hideAttribution = false,
8788
hideItinerary = false,
89+
isPathfindingLoading = false,
8890
preventPointSelection = false,
8991
id,
9092
simulationPathSteps,
@@ -135,6 +137,7 @@ const NewMap = ({
135137
);
136138

137139
const mapRef = useRef<MapRef | null>(null);
140+
const mapContainer = useMemo(() => mapRef.current?.getContainer(), [mapRef.current]);
138141

139142
const scaleControlStyle = {
140143
left: 20,
@@ -246,11 +249,15 @@ const NewMap = ({
246249
coordinates: compact(simulationPathSteps.map((step) => step.coordinates)),
247250
type: 'LineString',
248251
};
249-
if (points.coordinates.length > 2) {
250-
const newViewport = computeBBoxViewport(bbox(points), mapViewport);
252+
if (points.coordinates.length > 2 && !isPathfindingLoading) {
253+
const newViewport = computeBBoxViewport(bbox(points), mapViewport, {
254+
width: mapContainer?.clientWidth,
255+
height: mapContainer?.clientHeight,
256+
padding: 60,
257+
});
251258
updateViewportChange(newViewport);
252259
}
253-
}, [pathGeometry, simulationPathSteps]);
260+
}, [pathGeometry, simulationPathSteps, mapContainer, isPathfindingLoading]);
254261

255262
return (
256263
<>

0 commit comments

Comments
 (0)