@@ -267,9 +267,14 @@ L.LayerGroup.include({
267
267
} ,
268
268
269
269
snakePlay : function ( ) {
270
- this . _snakingLayers . map ( item => {
270
+ const findLast = this . _snakingLayers . some ( ( itm ) => itm . _snaking ) ;
271
+ var goPlay = null ;
272
+ this . _snakingLayers . map ( function ( item ) {
271
273
if ( item . _map && item . _snaking ) item . snakePlay ( ) ;
272
274
} ) ;
275
+ if ( findLast ) {
276
+ if ( goPlay ) goPlay . snakePlay ( ) ;
277
+ } else this . _snakeNext ( ) ;
273
278
} ,
274
279
// change position. This function stopping work of animation and initiate polylines with default state. Need timestamp
275
280
changePosition : function ( value ) {
@@ -440,18 +445,19 @@ L.LayerGroup.include({
440
445
_initiateStartPosition : function ( ) {
441
446
if ( this . _options . startPosition === "full" ) {
442
447
if ( this . _options . progressFormat === "default" ) {
443
- this . changePosition ( this . _originalLatlngs . length - 1 ) ;
448
+ this . changePosition ( this . _originalLatlngs . length ) ;
444
449
} else if ( this . _options . progressFormat === "distance" ) {
445
450
const max = this . _detailDistance . reduce ( ( result , item ) => {
446
451
result = result + item ;
447
452
return result ;
448
453
} , 0 ) ;
449
- this . changePosition ( max ) ;
454
+ this . changePosition ( max + 1 ) ;
450
455
} else if ( this . _options . progressFormat === "time" ) {
451
456
this . changePosition (
452
- this . _originalLatlngs [ this . _originalLatlngs . length - 1 ] . t
457
+ this . _originalLatlngs [ this . _originalLatlngs . length - 1 ] . t + 1
453
458
) ;
454
459
}
460
+ this . _snaking = false ;
455
461
this . _end ( true ) ;
456
462
} else {
457
463
this . changePosition ( this . _options . startPosition ) ;
@@ -460,7 +466,9 @@ L.LayerGroup.include({
460
466
} ,
461
467
462
468
_snakeNext : function ( ) {
463
- console . log ( this ) ;
469
+ if ( ! this . _snaking && this . _snakingLayersDone < this . _snakingLayers . length ) {
470
+ this . _snaking = true ;
471
+ }
464
472
if ( this . _snakingLayersDone >= this . _snakingLayers . length ) {
465
473
this . _end ( true ) ;
466
474
this . _snaking = false ;
@@ -487,6 +495,8 @@ L.LayerGroup.include({
487
495
} ) ;
488
496
this . _snakingLayers [ prevRange + index ] . removePosition ( ) ;
489
497
} ) ;
490
- this . snakePlay ( ) ;
498
+ if ( ! this . _snaking ) {
499
+ this . snakePlay ( ) ;
500
+ }
491
501
}
492
502
} ) ;
0 commit comments