@@ -395,7 +395,7 @@ if (typeof module !== undefined) module.exports = polyline;
395
395
( function ( ) {
396
396
'use strict' ;
397
397
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 ) ;
399
399
400
400
L . Routing = L . Routing || { } ;
401
401
L . extend ( L . Routing , require ( './L.Routing.Itinerary' ) ) ;
@@ -637,6 +637,8 @@ if (typeof module !== undefined) module.exports = polyline;
637
637
_updateLineCallback : function ( err , routes ) {
638
638
if ( ! err ) {
639
639
this . _updateLines ( { route : routes [ 0 ] , alternatives : routes . slice ( 1 ) } ) ;
640
+ } else {
641
+ this . _clearLines ( ) ;
640
642
}
641
643
} ,
642
644
@@ -707,7 +709,7 @@ if (typeof module !== undefined) module.exports = polyline;
707
709
( function ( ) {
708
710
'use strict' ;
709
711
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 ) ;
711
713
712
714
L . Routing = L . Routing || { } ;
713
715
@@ -736,30 +738,39 @@ if (typeof module !== undefined) module.exports = polyline;
736
738
737
739
formatDistance : function ( d /* Number (meters) */ , sensitivity ) {
738
740
var un = this . options . unitNames ,
741
+ simpleRounding = sensitivity <= 0 ,
742
+ round = simpleRounding ? function ( v ) { return v ; } : L . bind ( this . _round , this ) ,
739
743
v ,
740
- data ;
744
+ yards ,
745
+ data ,
746
+ pow10 ;
741
747
742
748
if ( this . options . units === 'imperial' ) {
743
- d = d / 1.609344 ;
744
- if ( d >= 1000 ) {
749
+ yards = d / 0.9144 ;
750
+ if ( yards >= 1000 ) {
745
751
data = {
746
- value : ( this . _round ( d ) / 1000 , sensitivity ) ,
752
+ value : round ( d / 1609.344 , sensitivity ) ,
747
753
unit : un . miles
748
754
} ;
749
755
} else {
750
756
data = {
751
- value : this . _round ( d / 1.760 , sensitivity ) ,
757
+ value : round ( yards , sensitivity ) ,
752
758
unit : un . yards
753
759
} ;
754
760
}
755
761
} else {
756
- v = this . _round ( d , sensitivity ) ;
762
+ v = round ( d , sensitivity ) ;
757
763
data = {
758
764
value : v >= 1000 ? ( v / 1000 ) : v ,
759
765
unit : v >= 1000 ? un . kilometers : un . meters
760
766
} ;
761
767
}
762
768
769
+ if ( simpleRounding ) {
770
+ pow10 = Math . pow ( 10 , - sensitivity ) ;
771
+ data . value = Math . round ( data . value * pow10 ) / pow10 ;
772
+ }
773
+
763
774
return L . Util . template ( this . options . distanceTemplate , data ) ;
764
775
} ,
765
776
@@ -846,7 +857,7 @@ if (typeof module !== undefined) module.exports = polyline;
846
857
( function ( ) {
847
858
'use strict' ;
848
859
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 ) ;
850
861
L . Routing = L . Routing || { } ;
851
862
L . extend ( L . Routing , require ( './L.Routing.Autocomplete' ) ) ;
852
863
@@ -1002,7 +1013,7 @@ if (typeof module !== undefined) module.exports = polyline;
1002
1013
( function ( ) {
1003
1014
'use strict' ;
1004
1015
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 ) ;
1006
1017
1007
1018
L . Routing = L . Routing || { } ;
1008
1019
L . extend ( L . Routing , require ( './L.Routing.Formatter' ) ) ;
@@ -1025,7 +1036,7 @@ if (typeof module !== undefined) module.exports = polyline;
1025
1036
alternativeClassName : '' ,
1026
1037
minimizedClassName : '' ,
1027
1038
itineraryClassName : '' ,
1028
- totalDistanceRoundingSensitivity : 10 ,
1039
+ totalDistanceRoundingSensitivity : - 1 ,
1029
1040
show : true ,
1030
1041
collapsible : undefined ,
1031
1042
collapseBtn : function ( itinerary ) {
@@ -1239,7 +1250,7 @@ if (typeof module !== undefined) module.exports = polyline;
1239
1250
( function ( ) {
1240
1251
'use strict' ;
1241
1252
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 ) ;
1243
1254
L . Routing = L . Routing || { } ;
1244
1255
1245
1256
L . Routing . ItineraryBuilder = L . Class . extend ( {
@@ -1290,7 +1301,7 @@ if (typeof module !== undefined) module.exports = polyline;
1290
1301
( function ( ) {
1291
1302
'use strict' ;
1292
1303
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 ) ;
1294
1305
1295
1306
L . Routing = L . Routing || { } ;
1296
1307
@@ -1835,7 +1846,7 @@ if (typeof module !== undefined) module.exports = polyline;
1835
1846
( function ( ) {
1836
1847
'use strict' ;
1837
1848
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 ) ,
1839
1850
corslite = require ( 'corslite' ) ,
1840
1851
polyline = require ( 'polyline' ) ;
1841
1852
@@ -1868,7 +1879,7 @@ if (typeof module !== undefined) module.exports = polyline;
1868
1879
wp ,
1869
1880
i ;
1870
1881
1871
- url = this . buildRouteUrl ( waypoints , L . extend ( options || { } , this . options . routingOptions ) ) ;
1882
+ url = this . buildRouteUrl ( waypoints , L . extend ( { } , this . options . routingOptions , options ) ) ;
1872
1883
1873
1884
timer = setTimeout ( function ( ) {
1874
1885
timedOut = true ;
@@ -1962,10 +1973,10 @@ if (typeof module !== undefined) module.exports = polyline;
1962
1973
1963
1974
_decodePolyline : function ( routeGeometry ) {
1964
1975
var cs = polyline . decode ( routeGeometry , 6 ) ,
1965
- result = [ ] ,
1976
+ result = new Array ( cs . length ) ,
1966
1977
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 ] ) ;
1969
1980
}
1970
1981
1971
1982
return result ;
@@ -2125,6 +2136,7 @@ if (typeof module !== undefined) module.exports = polyline;
2125
2136
for ( i = 0 ; i < indices . length ; i ++ ) {
2126
2137
indices [ i ] = Math . min ( maxCoordIndex , Math . max ( indices [ i ] , 0 ) ) ;
2127
2138
}
2139
+ return indices ;
2128
2140
}
2129
2141
} ) ;
2130
2142
@@ -2141,12 +2153,12 @@ if (typeof module !== undefined) module.exports = polyline;
2141
2153
( function ( ) {
2142
2154
'use strict' ;
2143
2155
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 ) ;
2145
2157
L . Routing = L . Routing || { } ;
2146
2158
L . extend ( L . Routing , require ( './L.Routing.GeocoderElement' ) ) ;
2147
2159
L . extend ( L . Routing , require ( './L.Routing.Waypoint' ) ) ;
2148
2160
2149
- L . Routing . Plan = L . Class . extend ( {
2161
+ L . Routing . Plan = L . Layer . extend ( {
2150
2162
includes : L . Mixin . Events ,
2151
2163
2152
2164
options : {
@@ -2493,7 +2505,7 @@ if (typeof module !== undefined) module.exports = polyline;
2493
2505
( function ( ) {
2494
2506
'use strict' ;
2495
2507
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 ) ;
2497
2509
L . Routing = L . Routing || { } ;
2498
2510
2499
2511
L . Routing . Waypoint = L . Class . extend ( {
0 commit comments