@@ -267,9 +267,14 @@ L.LayerGroup.include({
267267 } ,
268268
269269 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 ) {
271273 if ( item . _map && item . _snaking ) item . snakePlay ( ) ;
272274 } ) ;
275+ if ( findLast ) {
276+ if ( goPlay ) goPlay . snakePlay ( ) ;
277+ } else this . _snakeNext ( ) ;
273278 } ,
274279 // change position. This function stopping work of animation and initiate polylines with default state. Need timestamp
275280 changePosition : function ( value ) {
@@ -440,18 +445,19 @@ L.LayerGroup.include({
440445 _initiateStartPosition : function ( ) {
441446 if ( this . _options . startPosition === "full" ) {
442447 if ( this . _options . progressFormat === "default" ) {
443- this . changePosition ( this . _originalLatlngs . length - 1 ) ;
448+ this . changePosition ( this . _originalLatlngs . length ) ;
444449 } else if ( this . _options . progressFormat === "distance" ) {
445450 const max = this . _detailDistance . reduce ( ( result , item ) => {
446451 result = result + item ;
447452 return result ;
448453 } , 0 ) ;
449- this . changePosition ( max ) ;
454+ this . changePosition ( max + 1 ) ;
450455 } else if ( this . _options . progressFormat === "time" ) {
451456 this . changePosition (
452- this . _originalLatlngs [ this . _originalLatlngs . length - 1 ] . t
457+ this . _originalLatlngs [ this . _originalLatlngs . length - 1 ] . t + 1
453458 ) ;
454459 }
460+ this . _snaking = false ;
455461 this . _end ( true ) ;
456462 } else {
457463 this . changePosition ( this . _options . startPosition ) ;
@@ -460,7 +466,9 @@ L.LayerGroup.include({
460466 } ,
461467
462468 _snakeNext : function ( ) {
463- console . log ( this ) ;
469+ if ( ! this . _snaking && this . _snakingLayersDone < this . _snakingLayers . length ) {
470+ this . _snaking = true ;
471+ }
464472 if ( this . _snakingLayersDone >= this . _snakingLayers . length ) {
465473 this . _end ( true ) ;
466474 this . _snaking = false ;
@@ -487,6 +495,8 @@ L.LayerGroup.include({
487495 } ) ;
488496 this . _snakingLayers [ prevRange + index ] . removePosition ( ) ;
489497 } ) ;
490- this . snakePlay ( ) ;
498+ if ( ! this . _snaking ) {
499+ this . snakePlay ( ) ;
500+ }
491501 }
492502} ) ;
0 commit comments