L.AnimatedMarker=L.Marker.extend({options:{distance:200,interval:1e3,autoStart:!0,onEnd:function(){},clickable:!1},initialize:function(e,t){L.DomUtil.TRANSITION?this._latlngs=e:(this._latlngs=this._chunk(e),this.options.distance=10,this.options.interval=30),L.Marker.prototype.initialize.call(this,e[0],t)},_chunk:function(e){var t,n=e.length,r=[];for(t=1;t<n;t++){var i=e[t-1],s=e[t],o=i.distanceTo(s),u=this.options.distance/o,a=u*(s.lat-i.lat),f=u*(s.lng-i.lng);if(o>this.options.distance)while(o>this.options.distance)i=new L.LatLng(i.lat+a,i.lng+f),o=i.distanceTo(s),r.push(i);else r.push(i)}return r},onAdd:function(e){L.Marker.prototype.onAdd.call(this,e),this.options.autoStart&&this.start()},animate:function(){var e=this,t=this._latlngs.length,n=this.options.interval;this._i<t&&(n=this._latlngs[this._i-1].distanceTo(this._latlngs[this._i])/this.options.distance*this.options.interval),L.DomUtil.TRANSITION&&(this._icon&&(this._icon.style[L.DomUtil.TRANSITION]="all "+n+"ms linear"),this._shadow&&(this._shadow.style[L.DomUtil.TRANSITION]="all "+n+"ms linear")),this.setLatLng(this._latlngs[this._i]),this._i++,this._tid=setTimeout(function(){e._i===t?e.options.onEnd.apply(e,Array.prototype.slice.call(arguments)):e.animate()},n)},start:function(){this._i||(this._i=1),this.animate()},stop:function(){this._tid&&clearTimeout(this._tid)}}),L.animatedMarker=function(e,t){return new L.AnimatedMarker(e,t)};