@@ -797,6 +797,14 @@ class MyAccount {
797797 * @param {* } route
798798 */
799799 downloadRoute ( route ) {
800+ if ( ! Globals . online ) {
801+ Toast . show ( {
802+ text : "Fonctionnalité indisponible en mode hors ligne." ,
803+ duration : "long" ,
804+ position : "bottom"
805+ } ) ;
806+ return ;
807+ }
800808 let coordinates = [ ] ;
801809 route . data . steps . forEach ( ( step ) => {
802810 coordinates = coordinates . concat ( step . geometry . coordinates ) ;
@@ -874,6 +882,54 @@ class MyAccount {
874882 Globals . routeDraw . showDetails ( ) ;
875883 }
876884
885+ /**
886+ * Ouvre le suivi d'itinéraire
887+ * @param {* } route
888+ */
889+ followRoute ( route ) {
890+ let steps = JSON . parse ( JSON . stringify ( route . data . steps ) ) ;
891+ const coords = [ ] ;
892+ steps . forEach ( ( step ) => {
893+ coords . push ( step . geometry . coordinates ) ;
894+ } ) ;
895+ const dissolvedCoords = gisUtils . geoJsonMultiLineStringCoordsToSingleLineStringCoords ( coords ) ;
896+
897+ const routeLine = {
898+ type : "Feature" ,
899+ geometry : {
900+ type : "LineString" ,
901+ coordinates : dissolvedCoords ,
902+ } ,
903+ properties : {
904+ distance : route . data . distance ,
905+ duration : route . data . duration ,
906+ } ,
907+ } ;
908+ Globals . routeFollow . setData ( {
909+ routeLine : routeLine ,
910+ elevations : route . data . elevationData . elevationData ,
911+ } ) ;
912+ this . hide ( ) ;
913+ Globals . routeFollow . show ( ) ;
914+ }
915+
916+ /**
917+ * Ouvre le suivi d'itinéraire à partir de son ID
918+ * @param {Number } routeId
919+ */
920+ followRouteFromID ( routeId ) {
921+ try {
922+ this . followRoute ( this . #getRouteFromID( routeId ) ) ;
923+ } catch ( e ) {
924+ console . warn ( e ) ;
925+ Toast . show ( {
926+ text : "L'itinéraire n'a pas pu être ouvert." ,
927+ duration : "short" ,
928+ position : "bottom"
929+ } ) ;
930+ }
931+ }
932+
877933 /**
878934 * Ouvre l'outil de création de point de repère pour le modifer
879935 * @param {* } landmark
0 commit comments