qd-changjing/public/static/leaflet/leaflet.motion.min.js

12 lines
14 KiB
JavaScript
Raw Permalink Normal View History

2022-07-05 16:56:29 +08:00
/*!
*
* leaflet.motion - v0.3.2 (https://github.com/Igor-Vladyka/leaflet.motion#readme)
* Animation plugin for Leaflet.js
*
* MIT (http://www.opensource.org/licenses/mit-license.php)
* (c) 2022 Igor Vladyka <igor.vladyka@gmail.com> (https://github.com/Igor-Vladyka/)
*
*/
!function(t){var n={};function i(e){if(n[e])return n[e].exports;var o=n[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,i),o.l=!0,o.exports}i.m=t,i.c=n,i.d=function(t,n,e){i.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:e})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,n){if(1&n&&(t=i(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(i.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)i.d(e,o,function(n){return t[n]}.bind(null,o));return e},i.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(n,"a",n),n},i.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},i.p="",i(i.s=0)}([function(t,n,i){i(1),i(2),i(3),i(4),i(5),i(6),t.exports=i(7)},function(t,n){L.Motion=L.Motion||{Event:{Started:"motion-started",Paused:"motion-paused",Resumed:"motion-resumed",Section:"motion-section",Ended:"motion-ended"}},L.motion=L.motion||{},L.Motion.Animate={options:{pane:"polymotionPane",attribution:"Leaflet.Motion © "+(new Date).getFullYear()+" Igor Vladyka"},motionOptions:{auto:!1,easing:function(t){return t},speed:0,duration:0},markerOptions:void 0,initialize:function(t,n,i,e){L.Util.setOptions(this,n),i&&(this.motionOptions=L.Util.extend({},this.motionOptions,i)),e&&(this.markerOptions=L.Util.extend({},e)),this._bounds=L.latLngBounds(),this._linePoints=this._convertLatLngs(t),L.Motion.Utils.isFlat(this._linePoints)||(this._linePoints=this._linePoints[0]),this._initializeMarker(),this._latlngs=[],L.Util.stamp(this)},addLatLng:function(t,n){return t=L.Motion.Utils.toLatLng(t),this._linePoints.push(t),this._latlngs.length&&this._latlngs.push(t),this},beforeAdd:function(t){t.getPane(this.options.pane)||(t.createPane(this.options.pane).style.zIndex=599),this._renderer=t.getRenderer(this)},onAdd:function(t){return this._renderer._initPath(this),this._reset(),this._renderer._addPath(this),this.__marker&&this.markerOptions.showMarker&&(this.__marker.addTo(t),this.__marker._icon&&this.__marker._icon.children.length&&Array.from(this.__marker._icon.children).forEach((function(t){var n=t.getAttribute("motion-base");n&&(t.style.transform="rotate("+n+"deg)")}))),this.motionOptions.auto&&this.motionStart(),this},onRemove:function(t){this.motionStop(),this.__marker&&t.removeLayer(this.__marker),this._renderer._removePath(this)},_motion:function(t){var n=(new Date).getTime()-t,i=1;if(this.motionOptions.duration&&(i=n/this.motionOptions.duration),i<1){i=this.motionOptions.easing(i,n,0,1,this.motionOptions.duration);var e=L.Motion.Utils.interpolateOnLine(this._map,this._linePoints,i);this.setLatLngs(e.traveledPath),this._drawMarker(e.latLng),this.__ellapsedTime=n,this.animation=L.Util.requestAnimFrame((function(){this._motion(t)}),this)}else this.motionStop(!0)},_drawMarker:function(t){var n=this.getMarker();if(n){var i=n.getLatLng(),e=this._linePoints[0];i.lat===e.lat&&i.lng===e.lng?(n.addTo(this._map),n.addEventParent(this)):n._icon&&n._icon.children.length&&Array.from(n._icon.children).forEach((function(n){var e=n.getAttribute("motion-base");if(e){var o=0;e&&!isNaN(+e)&&(o=+e),n.style.transform="rotate(-"+Math.round(L.Motion.Utils.getAngle(i,t)+o)+"deg)"}})),n.setLatLng(t)}},_removeMarker:function(t){this.markerOptions&&this.__marker&&(t&&!this.markerOptions.removeOnEnd||this._map.removeLayer(this.__marker))},_initializeMarker:function(){this.markerOptions&&(this.__marker=L.marker(this._linePoints[0],this.markerOptions))},motionStart:function(){return this._map&&!this.animation&&(this.motionOptions.duration||(this.motionOptions.speed?this.motionOptions.duration=L.Motion.Utils.getDuration(this._map,this._linePoints,this.motionOptions.speed):this.motionOptions.duration=0),this.setLatLngs([]),this._motion((new Date).getTime()),this.fire(L.Motion.Event.Started,{layer:this},!1)),this},motionStop:function(t){return this.motionPause(),th