@@ -49,6 +49,7 @@ import RenderPopup from 'modules/trainschedule/components/ManageTrainSchedule/Ma
49
49
import { updateViewport } from 'reducers/map' ;
50
50
import type { Viewport } from 'reducers/map' ;
51
51
import { getMap , getTerrain3DExaggeration } from 'reducers/map/selectors' ;
52
+ import type { PathStep } from 'reducers/osrdconf/types' ;
52
53
import { getTrainScheduleV2Activated } from 'reducers/user/userSelectors' ;
53
54
import { useAppDispatch } from 'store' ;
54
55
import { getMapMouseEventNearestFeature } from 'utils/mapHelper' ;
@@ -61,13 +62,17 @@ type MapProps = {
61
62
setMapCanvas ?: ( mapCanvas : string ) => void ;
62
63
hideAttribution ?: boolean ;
63
64
hideItinerary ?: boolean ;
65
+ mapId ?: string ;
66
+ simulationPathSteps ?: PathStep [ ] ;
64
67
} ;
65
68
66
69
const Map = ( {
67
70
pathProperties,
68
71
setMapCanvas,
69
72
hideAttribution = false ,
70
73
hideItinerary = false ,
74
+ mapId = 'map-container' ,
75
+ simulationPathSteps,
71
76
} : MapProps ) => {
72
77
const mapBlankStyle = useMapBlankStyle ( ) ;
73
78
@@ -193,24 +198,14 @@ const Map = ({
193
198
// eslint-disable-next-line react-hooks/exhaustive-deps
194
199
} , [ ] ) ;
195
200
196
- useEffect ( ( ) => {
197
- if ( pathProperties ) {
198
- if ( setMapCanvas ) {
199
- setShowLayers ( false ) ;
200
- }
201
- const newViewport = computeBBoxViewport ( bbox ( pathProperties . geometry ) , viewport ) ;
202
- dispatch ( updateViewport ( newViewport ) ) ;
203
- }
204
- } , [ pathProperties ] ) ;
205
-
206
201
const captureMap = async ( ) => {
207
202
if ( ! pathProperties ) return ;
208
203
209
204
const itineraryViewport = computeBBoxViewport ( bbox ( pathProperties . geometry ) , viewport ) ;
210
205
211
206
if ( setMapCanvas && ! showLayers && isEqual ( viewport , itineraryViewport ) ) {
212
207
try {
213
- const mapElement = document . getElementById ( 'map-container' ) ;
208
+ const mapElement = document . getElementById ( mapId ) ;
214
209
if ( mapElement ) {
215
210
const canvas = await html2canvas ( mapElement ) ;
216
211
setMapCanvas ( canvas . toDataURL ( ) ) ;
@@ -223,6 +218,17 @@ const Map = ({
223
218
}
224
219
} ;
225
220
221
+ useEffect ( ( ) => {
222
+ if ( pathProperties ) {
223
+ if ( setMapCanvas ) {
224
+ setShowLayers ( false ) ;
225
+ captureMap ( ) ;
226
+ }
227
+ const newViewport = computeBBoxViewport ( bbox ( pathProperties . geometry ) , viewport ) ;
228
+ dispatch ( updateViewport ( newViewport ) ) ;
229
+ }
230
+ } , [ pathProperties ] ) ;
231
+
226
232
return (
227
233
< >
228
234
< MapButtons
@@ -262,7 +268,7 @@ const Map = ({
262
268
} }
263
269
onIdle = { ( ) => captureMap ( ) }
264
270
preserveDrawingBuffer
265
- id = "map-container"
271
+ id = { mapId }
266
272
>
267
273
< VirtualLayers />
268
274
{ ! hideAttribution && (
@@ -384,7 +390,12 @@ const Map = ({
384
390
geometry = { pathProperties ?. geometry }
385
391
hideItineraryLine = { hideItinerary }
386
392
/>
387
- { mapRef . current && < ItineraryMarkersV2 map = { mapRef . current . getMap ( ) } /> }
393
+ { mapRef . current && (
394
+ < ItineraryMarkersV2
395
+ simulationPathSteps = { simulationPathSteps }
396
+ map = { mapRef . current . getMap ( ) }
397
+ />
398
+ ) }
388
399
</ >
389
400
) : (
390
401
< >
0 commit comments