- map.fitBounds(polyline.getBounds().pad(0.05));
- }
-
- const distanceText = $("<p>").append(
- OSM.i18n.t("javascripts.directions.distance") + ": " + formatTotalDistance(route.distance) + ". " +
- OSM.i18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".");
- if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
- distanceText.append(
- $("<br>"),
- OSM.i18n.t("javascripts.directions.ascend") + ": " + formatHeight(route.ascend) + ". " +
- OSM.i18n.t("javascripts.directions.descend") + ": " + formatHeight(route.descend) + ".");
- }
-
- const turnByTurnTable = $("<table class='table table-hover table-sm mb-3'>")
- .append($("<tbody>"));
-
- $("#directions_content")
- .empty()
- .append(
- distanceText,
- turnByTurnTable
- );
-
- // Add each row
- for (const [i, [direction, instruction, dist, lineseg]] of route.steps.entries()) {
- const row = $("<tr class='turn'/>").appendTo(turnByTurnTable);
-
- if (direction) {
- row.append("<td class='border-0'><svg width='20' height='20' class='d-block'><use href='#routing-sprite-" + direction + "' /></svg></td>");
- } else {
- row.append("<td class='border-0'>");
- }
- row.append(`<td><b>${i + 1}.</b> ${instruction}`);
- row.append("<td class='distance text-body-secondary text-end'>" + formatStepDistance(dist));
-
- row.on("click", function () {
- popup
- .setLatLng(lineseg[0])
- .setContent(`<p><b>${i + 1}.</b> ${instruction}</p>`)
- .openOn(map);
- });
-
- row.hover(function () {
- highlight
- .setLatLngs(lineseg)
- .addTo(map);
- }, function () {
- map.removeLayer(highlight);
- });