@@ -41,7 +41,8 @@ let DirectionsResultsDOM = {
4141 data . distance ,
4242 data . duration ,
4343 data . transport ,
44- data . computation
44+ data . computation ,
45+ data . waypoints ,
4546 ) ) ;
4647 // ajout du bouton détails
4748 noDetailsDiv . appendChild ( this . __addResultsDetailsContainerDOMElement ( ) ) ;
@@ -79,7 +80,7 @@ let DirectionsResultsDOM = {
7980 * @returns {DOMElement }
8081 * @private
8182 */
82- __addResultsSummaryContainerDOMElement ( distance , duration , transport , computation ) {
83+ __addResultsSummaryContainerDOMElement ( distance , duration , transport , computation , waypoints = [ ] ) {
8384 var div = document . createElement ( "div" ) ;
8485 div . id = "directionsSummary" ;
8586 div . className = "" ;
@@ -109,6 +110,19 @@ let DirectionsResultsDOM = {
109110 labelComputation . className = "lblDirectionsSummaryComputation" ;
110111 labelComputation . textContent = computation ;
111112 line2 . appendChild ( labelComputation ) ;
113+ if ( transport === "Velo" ) {
114+ var linkGeovelo = document . createElement ( "a" ) ;
115+ const start = waypoints . shift ( ) ;
116+ const end = waypoints . pop ( ) ;
117+ linkGeovelo . href = `https://www.geovelo.app/route?from=${ start [ 0 ] } ,${ start [ 1 ] } &to=${ end [ 0 ] } ,${ end [ 1 ] } ` ;
118+ if ( waypoints . length > 0 ) {
119+ waypoints = waypoints . map ( point => `${ point [ 0 ] } ,${ point [ 1 ] } ` ) ;
120+ linkGeovelo . href += `&steps=${ waypoints . join ( ";" ) } ` ;
121+ }
122+ linkGeovelo . target = "_blank" ;
123+ linkGeovelo . textContent = "Navigation, détails et itinéraires alternatifs sur Géovélo" ;
124+ line2 . appendChild ( linkGeovelo ) ;
125+ }
112126
113127 div . appendChild ( line1 ) ;
114128 div . appendChild ( line2 ) ;
0 commit comments