@@ -340,7 +340,7 @@ export default {
340340 };
341341 });
342342
343- const routeDocuments = this .prepareRouteDocuments ();
343+ const routeDocuments = this .prepareRouteDocuments (false );
344344
345345 return [... baseDocuments, ... accessWaypointDocuments, ... routeDocuments];
346346 },
@@ -513,6 +513,9 @@ export default {
513513 this .calculateReturnParameters ();
514514 await this .determineReturnWaypoint ();
515515 }
516+
517+ // Trigger recenter after journey selection
518+ this .recenterMapOnDocuments ();
516519 } else {
517520 await this .fetchExtendedTimeframeJourney (fromCoords, toCoords, dateTimeFormat, dateTimeRepresents);
518521 }
@@ -522,13 +525,16 @@ export default {
522525 console .error (' Error retrieving routes:' , error);
523526 }
524527 if (this .queryError === ' no_solution' || this .queryError === ' unknown_object' ) {
525- await this .fetchExtendedTimeframeJourney (fromCoords, toCoords, dateTimeFormat, dateTimeRepresents);
528+ await this .fetchExtendedTimeframeJourney (fromCoords, toCoords, dateTimeFormat, dateTimeRepresents);
526529 } else {
527530 this .currentData .noResult = true ;
528531 this .currentData .journeys = [];
529532 }
530533 } finally {
531534 this .currentData .isUpdating = false ;
535+
536+ // Trigger recenter after processing
537+ this .recenterMapOnDocuments ();
532538 }
533539 },
534540
@@ -633,7 +639,7 @@ export default {
633639 },
634640
635641 /** Displays the routes of different transport on the map */
636- prepareRouteDocuments () {
642+ prepareRouteDocuments (scheduleRecenter = true ) {
637643 if (
638644 ! this .currentData .selectedRouteJourney ||
639645 ! this .currentData .journeys ||
@@ -751,11 +757,9 @@ export default {
751757 }
752758 });
753759
754- this .$nextTick (() => {
755- if (this .$refs .mapView ) {
756- this .$refs .mapView .recenterOnDocuments ();
757- }
758- });
760+ if (scheduleRecenter && this .$refs .mapView ) {
761+ this .recenterMapOnDocuments ();
762+ }
759763
760764 return routeDocuments;
761765 },
@@ -926,7 +930,8 @@ export default {
926930 accessPoints = [this .document ];
927931 } else {
928932 // for other types of documents, return the waypoints of type access associated (if any)
929- accessPoints = this .document ? .associations ? .waypoints ? .filter ((doc ) => doc && doc .waypoint_type === ' access' ) ?? [];
933+ accessPoints =
934+ this .document ? .associations ? .waypoints ? .filter ((doc ) => doc && doc .waypoint_type === ' access' ) ?? [];
930935 }
931936 const reachableChecks = [];
932937
@@ -1039,6 +1044,26 @@ export default {
10391044
10401045 return ` ${ durationInDays} ${ this .$gettext (' Day(s)' ).toLowerCase ()} ` ;
10411046 },
1047+
1048+ /** Helper method to recenter the map on documents if available */
1049+ recenterMapOnDocuments () {
1050+ this .$nextTick (() => {
1051+ // Only recenter if there are documents to recenter on
1052+ if (this .$refs .mapView && this .currentData .journeys && this .currentData .journeys .length > 0 ) {
1053+ this .$refs .mapView .recenterOnDocuments ();
1054+ }
1055+ });
1056+ },
1057+ },
1058+
1059+ watch: {
1060+ ' currentData.selectedRouteJourney' : {
1061+ handler () {
1062+ // Trigger recenter when selectedRouteJourney changes
1063+ this .recenterMapOnDocuments ();
1064+ },
1065+ deep: true ,
1066+ },
10421067 },
10431068};
10441069< / script>
0 commit comments