@@ -64,6 +64,7 @@ type MapProps = {
64
64
isReadOnly ?: boolean ;
65
65
hideAttribution ?: boolean ;
66
66
hideItinerary ?: boolean ;
67
+ isPathfindingLoading ?: boolean ;
67
68
preventPointSelection ?: boolean ;
68
69
id : string ;
69
70
simulationPathSteps : MarkerInformation [ ] ;
@@ -85,6 +86,7 @@ const NewMap = ({
85
86
isReadOnly = false ,
86
87
hideAttribution = false ,
87
88
hideItinerary = false ,
89
+ isPathfindingLoading = false ,
88
90
preventPointSelection = false ,
89
91
id,
90
92
simulationPathSteps,
@@ -135,6 +137,7 @@ const NewMap = ({
135
137
) ;
136
138
137
139
const mapRef = useRef < MapRef | null > ( null ) ;
140
+ const mapContainer = useMemo ( ( ) => mapRef . current ?. getContainer ( ) , [ mapRef . current ] ) ;
138
141
139
142
const scaleControlStyle = {
140
143
left : 20 ,
@@ -246,11 +249,15 @@ const NewMap = ({
246
249
coordinates : compact ( simulationPathSteps . map ( ( step ) => step . coordinates ) ) ,
247
250
type : 'LineString' ,
248
251
} ;
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
+ } ) ;
251
258
updateViewportChange ( newViewport ) ;
252
259
}
253
- } , [ pathGeometry , simulationPathSteps ] ) ;
260
+ } , [ pathGeometry , simulationPathSteps , mapContainer , isPathfindingLoading ] ) ;
254
261
255
262
return (
256
263
< >
0 commit comments