Skip to content

Commit a2b055c

Browse files
committed
3.0.0-beta.1
1 parent 5d15f7f commit a2b055c

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

dist/leaflet-routing-machine.js

+33-21
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ if (typeof module !== undefined) module.exports = polyline;
395395
(function() {
396396
'use strict';
397397

398-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
398+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
399399

400400
L.Routing = L.Routing || {};
401401
L.extend(L.Routing, require('./L.Routing.Itinerary'));
@@ -637,6 +637,8 @@ if (typeof module !== undefined) module.exports = polyline;
637637
_updateLineCallback: function(err, routes) {
638638
if (!err) {
639639
this._updateLines({route: routes[0], alternatives: routes.slice(1) });
640+
} else {
641+
this._clearLines();
640642
}
641643
},
642644

@@ -707,7 +709,7 @@ if (typeof module !== undefined) module.exports = polyline;
707709
(function() {
708710
'use strict';
709711

710-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
712+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
711713

712714
L.Routing = L.Routing || {};
713715

@@ -736,30 +738,39 @@ if (typeof module !== undefined) module.exports = polyline;
736738

737739
formatDistance: function(d /* Number (meters) */, sensitivity) {
738740
var un = this.options.unitNames,
741+
simpleRounding = sensitivity <= 0,
742+
round = simpleRounding ? function(v) { return v; } : L.bind(this._round, this),
739743
v,
740-
data;
744+
yards,
745+
data,
746+
pow10;
741747

742748
if (this.options.units === 'imperial') {
743-
d = d / 1.609344;
744-
if (d >= 1000) {
749+
yards = d / 0.9144;
750+
if (yards >= 1000) {
745751
data = {
746-
value: (this._round(d) / 1000, sensitivity),
752+
value: round(d / 1609.344, sensitivity),
747753
unit: un.miles
748754
};
749755
} else {
750756
data = {
751-
value: this._round(d / 1.760, sensitivity),
757+
value: round(yards, sensitivity),
752758
unit: un.yards
753759
};
754760
}
755761
} else {
756-
v = this._round(d, sensitivity);
762+
v = round(d, sensitivity);
757763
data = {
758764
value: v >= 1000 ? (v / 1000) : v,
759765
unit: v >= 1000 ? un.kilometers : un.meters
760766
};
761767
}
762768

769+
if (simpleRounding) {
770+
pow10 = Math.pow(10, -sensitivity);
771+
data.value = Math.round(data.value * pow10) / pow10;
772+
}
773+
763774
return L.Util.template(this.options.distanceTemplate, data);
764775
},
765776

@@ -846,7 +857,7 @@ if (typeof module !== undefined) module.exports = polyline;
846857
(function() {
847858
'use strict';
848859

849-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
860+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
850861
L.Routing = L.Routing || {};
851862
L.extend(L.Routing, require('./L.Routing.Autocomplete'));
852863

@@ -1002,7 +1013,7 @@ if (typeof module !== undefined) module.exports = polyline;
10021013
(function() {
10031014
'use strict';
10041015

1005-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
1016+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
10061017

10071018
L.Routing = L.Routing || {};
10081019
L.extend(L.Routing, require('./L.Routing.Formatter'));
@@ -1025,7 +1036,7 @@ if (typeof module !== undefined) module.exports = polyline;
10251036
alternativeClassName: '',
10261037
minimizedClassName: '',
10271038
itineraryClassName: '',
1028-
totalDistanceRoundingSensitivity: 10,
1039+
totalDistanceRoundingSensitivity: -1,
10291040
show: true,
10301041
collapsible: undefined,
10311042
collapseBtn: function(itinerary) {
@@ -1239,7 +1250,7 @@ if (typeof module !== undefined) module.exports = polyline;
12391250
(function() {
12401251
'use strict';
12411252

1242-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
1253+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
12431254
L.Routing = L.Routing || {};
12441255

12451256
L.Routing.ItineraryBuilder = L.Class.extend({
@@ -1290,7 +1301,7 @@ if (typeof module !== undefined) module.exports = polyline;
12901301
(function() {
12911302
'use strict';
12921303

1293-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
1304+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
12941305

12951306
L.Routing = L.Routing || {};
12961307

@@ -1835,7 +1846,7 @@ if (typeof module !== undefined) module.exports = polyline;
18351846
(function() {
18361847
'use strict';
18371848

1838-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null),
1849+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null),
18391850
corslite = require('corslite'),
18401851
polyline = require('polyline');
18411852

@@ -1868,7 +1879,7 @@ if (typeof module !== undefined) module.exports = polyline;
18681879
wp,
18691880
i;
18701881

1871-
url = this.buildRouteUrl(waypoints, L.extend(options || {}, this.options.routingOptions));
1882+
url = this.buildRouteUrl(waypoints, L.extend({}, this.options.routingOptions, options));
18721883

18731884
timer = setTimeout(function() {
18741885
timedOut = true;
@@ -1962,10 +1973,10 @@ if (typeof module !== undefined) module.exports = polyline;
19621973

19631974
_decodePolyline: function(routeGeometry) {
19641975
var cs = polyline.decode(routeGeometry, 6),
1965-
result = [],
1976+
result = new Array(cs.length),
19661977
i;
1967-
for (i = 0; i < cs.length; i++) {
1968-
result.push(L.latLng(cs[i]));
1978+
for (i = cs.length - 1; i >= 0; i--) {
1979+
result[i] = L.latLng(cs[i]);
19691980
}
19701981

19711982
return result;
@@ -2125,6 +2136,7 @@ if (typeof module !== undefined) module.exports = polyline;
21252136
for (i = 0; i < indices.length; i++) {
21262137
indices[i] = Math.min(maxCoordIndex, Math.max(indices[i], 0));
21272138
}
2139+
return indices;
21282140
}
21292141
});
21302142

@@ -2141,12 +2153,12 @@ if (typeof module !== undefined) module.exports = polyline;
21412153
(function() {
21422154
'use strict';
21432155

2144-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
2156+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
21452157
L.Routing = L.Routing || {};
21462158
L.extend(L.Routing, require('./L.Routing.GeocoderElement'));
21472159
L.extend(L.Routing, require('./L.Routing.Waypoint'));
21482160

2149-
L.Routing.Plan = L.Class.extend({
2161+
L.Routing.Plan = L.Layer.extend({
21502162
includes: L.Mixin.Events,
21512163

21522164
options: {
@@ -2493,7 +2505,7 @@ if (typeof module !== undefined) module.exports = polyline;
24932505
(function() {
24942506
'use strict';
24952507

2496-
var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null);
2508+
var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null);
24972509
L.Routing = L.Routing || {};
24982510

24992511
L.Routing.Waypoint = L.Class.extend({

0 commit comments

Comments
 (0)