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