From acf9c5988856d98c299380a692ea87b2720ba304 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 16 Apr 2021 19:07:52 +0200 Subject: [PATCH] Initial take on supporting straight line segments --- js/index.js | 2 +- js/plugin/Routing.js | 6 ++++-- package.json | 2 +- yarn.lock | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/js/index.js b/js/index.js index 8ef2fd3..be76e59 100644 --- a/js/index.js +++ b/js/index.js @@ -267,7 +267,7 @@ exportRoute = new BR.Export(router, pois, profile); - routing.on('routing:routeWaypointEnd routing:setWaypointsEnd', function (evt) { + routing.on('routing:routeWaypointEnd routing:setWaypointsEnd routing:rerouteSegmentEnd', function (evt) { search.clear(); onUpdate(evt && evt.err); }); diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index 5f80e85..115fab2 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -185,7 +185,9 @@ BR.Routing = L.Routing.extend({ }, _addSegmentCasing: function (e) { - var casing = L.polyline(e.layer.getLatLngs(), this.options.styles.trackCasing); + // extend layer style to inherit beeline dashArray + const casingStyle = Object.assign({}, e.layer.options, this.options.styles.trackCasing); + const casing = L.polyline(e.layer.getLatLngs(), casingStyle); this._segmentsCasing.addLayer(casing); e.layer._casing = casing; this._segments.bringToFront(); @@ -308,7 +310,7 @@ BR.Routing = L.Routing.extend({ this._eachSegment(function (m1, m2, line) { // omit if null (still calculating) or error // NOTE: feature check specific to BRouter GeoJSON response, workaround to detect error line - if (line && line.feature) { + if (line && (line.feature || m1._routing.beeline)) { latLngs = latLngs.concat(line.getLatLngs()); } }); diff --git a/package.json b/package.json index d36326e..717edb0 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "leaflet-hotline": "^0.4.0", "leaflet-plugins": "~3.0.0", "leaflet-providers": "^1.10.2", - "leaflet-routing": "nrenner/leaflet-routing#e94e153", + "leaflet-routing": "nrenner/leaflet-routing#9fa0cd2", "leaflet-sidebar-v2": "nrenner/leaflet-sidebar-v2#dev", "leaflet-triangle-marker": "^1.0.2", "leaflet.heightgraph": "nrenner/Leaflet.Heightgraph#0757b2a", diff --git a/yarn.lock b/yarn.lock index 8ec6618..55d8bfd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7806,9 +7806,9 @@ leaflet-providers@^1.10.2: resolved "https://registry.yarnpkg.com/leaflet-providers/-/leaflet-providers-1.10.2.tgz#763c8e6655f26caf1afe3a1ef4add6c3e32de663" integrity sha512-1l867LObxwuFBeyPeBewip8PAXKOnvEoujq4/9y2TKTiZNHH76ksBD6dfktGjgUrOF+IdjsGHkpASPE+v2DQLw== -leaflet-routing@nrenner/leaflet-routing#e94e153: - version "0.1.3" - resolved "https://codeload.github.com/nrenner/leaflet-routing/tar.gz/e94e153b7574510313cb0bfefcd8776edebf627e" +leaflet-routing@nrenner/leaflet-routing#9fa0cd2: + version "0.1.4-alpha" + resolved "https://codeload.github.com/nrenner/leaflet-routing/tar.gz/9fa0cd22984a206518c6e20b7a53255531763e88" leaflet-sidebar-v2@nrenner/leaflet-sidebar-v2#dev: version "3.0.2"