diff --git a/bower.json b/bower.json index a7f3db1..f795ba0 100644 --- a/bower.json +++ b/bower.json @@ -11,6 +11,6 @@ "leaflet-gpx": "mpetazzoni/leaflet-gpx", "leaflet-search": "*", "leaflet-plugins": "*", - "leaflet-routing": "Turistforeningen/leaflet-routing#gh-pages" + "leaflet-routing": "nrenner/leaflet-routing#reroute" } } diff --git a/bower_components/leaflet-routing/.bower.json b/bower_components/leaflet-routing/.bower.json index eda239e..25ef870 100644 --- a/bower_components/leaflet-routing/.bower.json +++ b/bower_components/leaflet-routing/.bower.json @@ -1,13 +1,13 @@ { "name": "leaflet-routing", - "homepage": "https://github.com/Turistforeningen/leaflet-routing", - "_release": "9d66697f2a", + "homepage": "https://github.com/nrenner/leaflet-routing", + "_release": "ac4d02c54b", "_resolution": { "type": "branch", - "branch": "gh-pages", - "commit": "9d66697f2a0e547b61a48c7a5358f5f0bba280fe" + "branch": "reroute", + "commit": "ac4d02c54b06da9d1e21fe77ba5a0c553095d15e" }, - "_source": "git://github.com/Turistforeningen/leaflet-routing.git", - "_target": "gh-pages", - "_originalSource": "Turistforeningen/leaflet-routing" + "_source": "git://github.com/nrenner/leaflet-routing.git", + "_target": "reroute", + "_originalSource": "nrenner/leaflet-routing" } \ No newline at end of file diff --git a/bower_components/leaflet-routing/README.md b/bower_components/leaflet-routing/README.md index 0fd4b10..9292a5e 100644 --- a/bower_components/leaflet-routing/README.md +++ b/bower_components/leaflet-routing/README.md @@ -39,6 +39,11 @@ routing.routing(true); routing.snapping(true); ``` +### Recalculate the complete route by routing each segment +```javascript +routing.routeAllSegments(callback); +``` + ### Get first waypoint ```javascript diff --git a/bower_components/leaflet-routing/src/L.Routing.js b/bower_components/leaflet-routing/src/L.Routing.js index 92b6b50..d4a3829 100644 --- a/bower_components/leaflet-routing/src/L.Routing.js +++ b/bower_components/leaflet-routing/src/L.Routing.js @@ -295,6 +295,43 @@ L.Routing = L.Control.extend({ this._routeSegment(marker, marker._routing.nextMarker, callback); } + /** + * Recalculate the complete route by routing each segment + * + * @access public + * + * @param cb - callback function + * + * @return void + * + * @todo add propper error checking for callback + */ + ,routeAllSegments: function(cb) { + var numSegments = this.getWaypoints().length - 1; + var callbackCount = 0; + var $this = this; + + var callback = function(err, data) { + callbackCount++; + if (callbackCount >= numSegments) { + $this.fire('routing:routeAllSegmentsEnd'); + if (cb) { + cb(err); + } + } + }; + + $this.fire('routing:routeAllSegmentsStart'); + + if (numSegments < 1) { + return callback(null, true); + } + + this._eachSegment(function(m1, m2) { + this._routeSegment(m1, m2, callback); + }); + } + /** * Route segment between two markers *