" + I18n.t("javascripts.directions.errors.no_route") + "
"); } return; } polyline .setLatLngs(route.line) .addTo(map); if (fitRoute) { map.fitBounds(polyline.getBounds().pad(0.05)); } var html = "" +
I18n.t("javascripts.directions.distance") + ": " + formatDistance(route.distance) + ". " +
I18n.t("javascripts.directions.time") + ": " + formatTime(route.time) + ".";
if (typeof route.ascend !== "undefined" && typeof route.descend !== "undefined") {
html += "
" +
I18n.t("javascripts.directions.ascend") + ": " + Math.round(route.ascend) + "m. " +
I18n.t("javascripts.directions.descend") + ": " + Math.round(route.descend) + "m.";
}
html += "
"); row.append(" | " + instruction); row.append(" | " + dist);
row.on("click", function () {
popup
.setLatLng(ll)
.setContent(" " + instruction + " ") .openOn(map); }); row.hover(function () { highlight .setLatLngs(lineseg) .addTo(map); }, function () { map.removeLayer(highlight); }); $("#turnbyturn").append(row); }); $("#sidebar_content").append("" + I18n.t("javascripts.directions.instructions.courtesy", { link: chosenEngine.creditline }) + " "); $("#sidebar_content a.geolink").on("click", function (e) { e.preventDefault(); map.removeLayer(polyline); $("#sidebar_content").html(""); map.setSidebarOverlaid(true); // TODO: collapse width of sidebar back to previous }); }); } var chosenEngineIndex = findEngine("fossgis_osrm_car"); if (Cookies.get("_osm_directions_engine")) { chosenEngineIndex = findEngine(Cookies.get("_osm_directions_engine")); } setEngine(chosenEngineIndex); select.on("change", function (e) { chosenEngine = engines[e.target.selectedIndex]; Cookies.set("_osm_directions_engine", chosenEngine.id, { secure: true, expires: expiry, path: "/", samesite: "lax" }); getRoute(true, true); }); $(".directions_form").on("submit", function (e) { e.preventDefault(); getRoute(true, true); }); $(".routing_marker").on("dragstart", function (e) { var dt = e.originalEvent.dataTransfer; dt.effectAllowed = "move"; var dragData = { type: $(this).data("type") }; dt.setData("text", JSON.stringify(dragData)); if (dt.setDragImage) { var img = $(" |