@@ -69,8 +69,12 @@ function checkIfEcoAndAddPrefix(allowancesSettings, id, baseKey) {
69
69
return baseKey ;
70
70
}
71
71
72
- function Map ( props ) {
72
+ interface MapProps {
73
+ setExtViewport : ( any ) => void ;
74
+ }
75
+ function Map ( props : MapProps ) {
73
76
const { setExtViewport } = props ;
77
+ const [ mapLoaded , setMapLoaded ] = useState ( false ) ;
74
78
const { viewport, mapSearchMarker, mapStyle, mapTrackSources, showOSM, layersSettings } =
75
79
useSelector ( ( state : RootState ) => state . map ) ;
76
80
const { isPlaying, selectedTrain, positionValues, timePosition, allowancesSettings } =
@@ -229,7 +233,7 @@ function Map(props) {
229
233
} ;
230
234
231
235
const onFeatureHover = ( e ) => {
232
- if ( ! isPlaying && e && geojsonPath ?. geometry ?. coordinates ) {
236
+ if ( mapLoaded && ! isPlaying && e && geojsonPath ?. geometry ?. coordinates ) {
233
237
const line = lineString ( geojsonPath . geometry . coordinates ) ;
234
238
const cursorPoint = point ( e . lngLat ) ;
235
239
const key = getRegimeKey ( simulation . trains [ selectedTrain ] . id ) ;
@@ -271,7 +275,7 @@ function Map(props) {
271
275
272
276
function defineInteractiveLayers ( ) {
273
277
const interactiveLayersLocal : string [ ] = [ ] ;
274
- if ( geojsonPath ) {
278
+ if ( mapLoaded && geojsonPath ) {
275
279
interactiveLayersLocal . push ( 'geojsonPath' ) ;
276
280
interactiveLayersLocal . push ( 'main-train-path' ) ;
277
281
otherTrainsHoverPosition . forEach ( ( train ) => {
@@ -315,6 +319,10 @@ function Map(props) {
315
319
}
316
320
} , [ timePosition ] ) ;
317
321
322
+ const handleLoadFinished = ( ) => {
323
+ setMapLoaded ( true ) ;
324
+ } ;
325
+
318
326
return (
319
327
< >
320
328
< MapButtons resetPitchBearing = { resetPitchBearing } />
@@ -333,6 +341,7 @@ function Map(props) {
333
341
interactiveLayerIds = { interactiveLayerIds }
334
342
touchRotate
335
343
asyncRender
344
+ onLoad = { handleLoadFinished }
336
345
>
337
346
< AttributionControl
338
347
className = "attribution-control"
0 commit comments