File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -418,9 +418,14 @@ ${gpxPoints}
418418 centerLat = selectedStartPoint [ 1 ] ;
419419 centerLon = selectedStartPoint [ 0 ] ;
420420 } else if ( routes . length > 0 ) {
421- const allCoords = routes . flatMap ( r => r . coordinates ) ;
422- centerLat = allCoords . reduce ( ( sum , [ , lat ] ) => sum + lat , 0 ) / allCoords . length ;
423- centerLon = allCoords . reduce ( ( sum , [ lon ] ) => sum + lon , 0 ) / allCoords . length ;
421+ const allCoords = routes . flatMap ( r => r . coordinates || [ ] ) ;
422+ if ( allCoords . length > 0 && Array . isArray ( allCoords [ 0 ] ) ) {
423+ centerLat = allCoords . reduce ( ( sum , coord ) => sum + ( Array . isArray ( coord ) ? coord [ 1 ] : 0 ) , 0 ) / allCoords . length ;
424+ centerLon = allCoords . reduce ( ( sum , coord ) => sum + ( Array . isArray ( coord ) ? coord [ 0 ] : 0 ) , 0 ) / allCoords . length ;
425+ } else {
426+ centerLat = 59.3293 ;
427+ centerLon = 18.0686 ;
428+ }
424429 } else {
425430 centerLat = 59.3293 ;
426431 centerLon = 18.0686 ;
You can’t perform that action at this time.
0 commit comments