Skip to content

Commit

Permalink
tooltip pour les itinéraires
Browse files Browse the repository at this point in the history
  • Loading branch information
cyril charignon committed Oct 26, 2023
1 parent 7a516ba commit efaeb97
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/classes/Itinéraire.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ export class Itinéraire {
this.couleur = couleur;
this.longueur = longueur;
this.pourcentage_détour = pourcentage_détour;
const contenu_popup = `${nom}<br>${longueur}km, ${Math.floor(longueur / 0.25)}mn`
let contenu_popup = `
${nom}<br>${longueur}km, ${Math.floor(longueur / 0.25)}mn`
+ (pourcentage_détour ? `,<br> détour de ${pourcentage_détour}%` : "");

//contenu_popup = `<div stlyle="background-color: ${this.couleur}">${contenu_popup}</div>`

this.polyline = new L.Polyline(
géomOsmVersLeaflet(points),
{
Expand All @@ -28,7 +30,19 @@ export class Itinéraire {
lineJoin: "miter",
}
)
.bindPopup(contenu_popup);
.bindTooltip(
contenu_popup,
{
//permanent: true,
}
)
.on("click",
e => {
e.originalEvent.stopPropagation();
e.originalEvent.stopImmediatePropagation();
this.polyline.toggleTooltip();
}
);

}
}

0 comments on commit efaeb97

Please sign in to comment.