/* 2020-9-22 15:23:19 | 版权所有 军懋国兴 */ function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"==("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.mapv=t.mapv||{})}(this,function(t){"use strict";function n(){this._subscribers={}}function O(t,e){n.bind(this)(),this._options=e||{},this._data=[],t&&this.add(t)}function g(t,e,n,i){for(var o,r,a,s,l=0;l<6;l++){var u=(o={x:e,y:n},r=i,s=a=void 0,a=60*l+30,s=Math.PI/180*a,[o.x+r*Math.cos(s),o.y+r*Math.sin(s)]);t.lineTo(u[0],u[1])}}function x(t,e){var n;return"undefined"==typeof document||(n=document.createElement("canvas"),t&&(n.width=t),e&&(n.height=e)),n}function I(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function l(r,t,a){var s=a.max||100,e=a.min||0,n=a._size;null!=n||null==(n=a.size)&&(n=13);var i,o,l,u,h,c,g,p=new I({gradient:a.gradient,max:s,min:e}),f=(u=new x(2*(l=(i=n)+(o=i/2)),2*l),(h=u.getContext("2d")).shadowBlur=o,h.shadowColor="black",h.shadowOffsetX=h.shadowOffsetY=1e4,h.beginPath(),h.arc(l-1e4,l-1e4,i,0,2*Math.PI,!0),h.closePath(),h.fill(),u),d=f.width/2,v=f.height/2,y=t,m={};for(c in y.forEach(function(t,e){var n=void 0===t.count?1:t.count,i=Math.min(1,n/s).toFixed(2);m[i]=m[i]||[],m[i].push(t)}),m){isNaN(c)||(g=m[c],r.beginPath(),a.withoutAlpha||(r.globalAlpha=c),r.strokeStyle=p.getColor(c*s),g.forEach(function(t,e){var n,i,o;t.geometry&&(n=t.geometry._coordinates||t.geometry.coordinates,"Point"===(i=t.geometry.type)?(o=void 0===t.count?1:t.count,r.globalAlpha=o/s,r.drawImage(f,n[0]-d,n[1]-v)):"LineString"===i&&(o=void 0===t.count?1:t.count,r.globalAlpha=o/s,r.beginPath(),F.draw(r,t,a),r.stroke()))}))}}function a(t,e,n){var i=t.createShader(n);return t.shaderSource(i,e),t.compileShader(i),i}function w(t,e,n){var i=a(t,e,t.VERTEX_SHADER),o=a(t,n,t.FRAGMENT_SHADER),r=t.createProgram();return t.attachShader(r,i),t.attachShader(r,o),t.linkProgram(r),t.useProgram(r),r}function _(t){var e=document.createElement("canvas"),n=e.getContext("2d");return e.width=1,e.height=1,n.fillStyle=t,n.fillRect(0,0,1,1),n.getImageData(0,0,1,1).data}function m(t,e,n){n=n||2;var i,o,r,a,s,l,u,h=e&&e.length,c=h?e[0]*n:t.length,g=d(t,0,c,n,!0),p=[];if(!g)return p;if(h&&(g=function(t,e,n,i){var o,r,a,s,l,u=[];for(o=0,r=e.length;o=i.next.y){var s=i.x+(r-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=o&&a=i.x&&i.x>=h&&S(rn.x)&&C(i,t)&&(n=i,g=l)),i=i.next;return n}(t,e))&&v(n=A(e,t),n.next)}})(u[o],n),n=v(n,n.next);return n}(t,e,g,n)),t.length>80*n){i=r=t[0],o=a=t[1];for(var f=n;fr.x?o.x>a.x?o.x:a.x:r.x>a.x?r.x:a.x,h=o.y>r.y?o.y>a.y?o.y:a.y:r.y>a.y?r.y:a.y,c=f(s,l,e,n,i),g=f(u,h,e,n,i),p=t.nextZ;p&&p.z<=g;){if(p!==t.prev&&p!==t.next&&S(o.x,o.y,r.x,r.y,a.x,a.y,p.x,p.y)&&0<=M(p.prev,p,p.next))return!1;p=p.nextZ}for(p=t.prevZ;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&S(o.x,o.y,r.x,r.y,a.x,a.y,p.x,p.y)&&0<=M(p.prev,p,p.next))return!1;p=p.prevZ}return!0}(t,i,o,r):function(t){var e=t.prev,n=t,i=t.next;if(0<=M(e,n,i))return!1;for(var o=t.next.next;o!==t.prev;){if(S(e.x,e.y,n.x,n.y,i.x,i.y,o.x,o.y)&&0<=M(o.prev,o,o.next))return!1;o=o.next}return!0}(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),p(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?y(t=function(t,e,n){var i=t;do{var o=i.prev,r=i.next.next;!h(o,r)&&c(o,i,i.next,r)&&C(o,r)&&C(r,o)&&(e.push(o.i/n),e.push(i.i/n),e.push(r.i/n),p(i),p(i.next),i=t=r),i=i.next}while(i!==t);return i}(t,e,n),e,n,i,o,r,2):2===a&&function(t,e,n,i,o,r){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&c(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&C(t,e)&&C(e,t)&&function(t,e){var n=t,i=!1,o=(t.x+e.x)/2,r=(t.y+e.y)/2;for(;n.y>r!=n.next.y>r&&o<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next,n!==t;);return i}(t,e)}(a,s)){var l=A(a,s);return a=v(a,a.next),l=v(l,l.next),y(a,e,n,i,o,r),y(l,e,n,i,o,r)}s=s.next}a=a.next}while(a!==t)}(t,e,n,i,o,r):y(v(t),e,n,i,o,r,1);break}}}function b(t,e){return t.x-e.x}function f(t,e,n,i,o){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)/o)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)/o)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function S(t,e,n,i,o,r,a,s){return 0<=(o-a)*(e-s)-(t-a)*(r-s)&&0<=(t-a)*(i-s)-(n-a)*(e-s)&&0<=(n-a)*(r-s)-(o-a)*(i-s)}function M(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function h(t,e){return t.x===e.x&&t.y===e.y}function c(t,e,n,i){return h(t,e)&&h(n,i)||h(t,i)&&h(n,e)||0o&&(t[r]=256*o),t[r-3]=e[i],t[r-2]=e[1+i],t[r-1]=e[2+i]}((a=o.getImageData(0,0,t.canvas.width,t.canvas.height)).data,s.getImageData(),n),t.putImageData(a,0,0),t.restore()),s=null}},U={draw:function(t,e,n){t.save();for(var i=e instanceof O?e.get():e,o={},r=n._size||n.size||50,a=n.offset||{x:0,y:0},s=0;s'+i+"";return n.innerHTML=o,n},o.prototype.get=function(t){for(var e=this.splitList,n=!1,i=0;i=e[i].start)&&(void 0===e[i].end||void 0!==e[i].end&&tn&&(e[u]._size=o),t.lineWidth=1,t.strokeStyle=e[u].strokeStyle||e[u]._strokeStyle||l.strokeStyle||"yellow",t.stroke(),(s=e[u].fillStyle||e[u]._fillStyle||l.fillStyle)&&(t.fillStyle=s,t.fill())):"LineString"===e[u].geometry.type&&(t.beginPath(),i=e[u].size||this.options.size||5,o=e[u].minSize||this.options.minSize||0,void 0===e[u]._index&&(e[u]._index=0),r=e[u]._index,t.arc(e[u].geometry._coordinates[r][0],e[u].geometry._coordinates[r][1],i,0,2*Math.PI,!0),t.closePath(),e[u]._index++,e[u]._index>=e[u].geometry._coordinates.length&&(e[u]._index=0),t.lineWidth=l.lineWidth||1,a=e[u].strokeStyle||l.strokeStyle,s=e[u].fillStyle||l.fillStyle||"yellow",t.fillStyle=s,t.fill(),a&&(t.strokeStyle=a,t.stroke()))}t.restore()}}},{key:"animate",value:function(){this.drawAnimation();var t=this.options.animateTime||100;this.timeout=setTimeout(this.animate.bind(this),t)}},{key:"start",value:function(){this.stop(),this.animate()}},{key:"stop",value:function(){clearTimeout(this.timeout)}},{key:"unbindEvent",value:function(){}},{key:"hide",value:function(){this.canvasLayer.hide(),this.stop()}},{key:"show",value:function(){this.start()}}]),xt),ft=function(t,e,n){return e&&mt(t.prototype,e),n&&mt(t,n),t},dt=(function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+_typeof(e));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(yt,ct),ft(yt,[{key:"clickEvent",value:function(t){var e=t.pixel;ht(yt.prototype.__proto__||Object.getPrototypeOf(yt.prototype),"clickEvent",this).call(this,e,t)}},{key:"mousemoveEvent",value:function(t){var e=t.pixel;ht(yt.prototype.__proto__||Object.getPrototypeOf(yt.prototype),"mousemoveEvent",this).call(this,e,t)}},{key:"bindEvent",value:function(){var t=this.map;this.options.methods&&(this.options.methods.click&&(t.setDefaultCursor("default"),t.addEventListener("click",this.clickEvent)),this.options.methods.mousemove&&t.addEventListener("mousemove",this.mousemoveEvent))}},{key:"unbindEvent",value:function(){var t=this.map;this.options.methods&&(this.options.methods.click&&t.removeEventListener("click",this.clickEvent),this.options.methods.mousemove&&t.removeEventListener("mousemove",this.mousemoveEvent))}},{key:"transferToMercator",value:function(){var t,n=this.map.getMapType().getProjection();"bd09mc"!==this.options.coordType&&(t=this.dataSet.get(),t=this.dataSet.transferCoordinate(t,function(t){var e=n.lngLatToPoint({lng:t[0],lat:t[1]});return[e.x,e.y]},"coordinates","coordinates_mercator"),this.dataSet._set(t))}},{key:"getContext",value:function(){return this.canvasLayer.canvas.getContext(this.context)}},{key:"_canvasUpdate",value:function(n){if(this.canvasLayer){var e,t,i,o,r=this,a=r.options.animation,s=this.canvasLayer._map,l=Math.pow(2,18-s.getZoom()),u=s.getMapType().getProjection().lngLatToPoint(s.getCenter()),h=new BMap.Pixel(u.x-s.getSize().width/2*l,u.y+s.getSize().height/2*l),c=this.getContext();if(r.isEnabledTime()){if(void 0===n)return void R(c);"2d"==this.context&&(c.save(),c.globalCompositeOperation="destination-out",c.fillStyle="rgba(0, 0, 0, .1)",c.fillRect(0,0,c.canvas.width,c.canvas.height),c.restore())}else R(c);if("2d"==this.context)for(var g in r.options)c[g]=r.options[g];else c.clear(c.COLOR_BUFFER_BIT);r.options.minZoom&&s.getZoom()r.options.maxZoom||(e=1,"2d"!=this.context&&(e=this.canvasLayer.devicePixelRatio),t={fromColumn:"bd09mc"==r.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-h.x)/l*e,(h.y-t[1])/l*e]}},void 0!==n&&(t.filter=function(t){var e=a.trails||10;return!!(n&&t.time>n-e&&t.timeh.options.maxZoom||(r=1,"2d"!=this.context&&(r=this.canvasLayer.devicePixelRatio),t=this.map,o=t.getProjection(),r=Math.pow(2,t.zoom)*resolutionScale,a=o.fromLatLngToPoint(this.canvasLayer.getTopLeft()),e={transferCoordinate:function(t){var e=new google.maps.LatLng(t[1],t[0]),n=o.fromLatLngToPoint(e),i={x:(n.x-a.x)*r,y:(n.y-a.y)*r};return[i.x,i.y]}},void 0!==n&&(e.filter=function(t){var e=c.trails||10;return!!(n&&t.time>n-e&&t.timel||Math.abs(s.y)>l)&&(a=1/Math.pow((n={source:_[o[r]][e],target:_[t][e]},Math.sqrt(Math.pow(n.source.x-n.target.x,2)+Math.pow(n.source.y-n.target.y,2))),1),i.x+=s.x*a,i.y+=s.y*a)}return i}function u(t,e,n){for(var i,o,r,a,s,l,u,h,c=b/(y(w[t])*(e+1)),g=[{x:0,y:0}],p=1;p=r)&&(g[n].push(i),g[i].push(n))}function e(){var t=p,e=M,n=1;(function(){for(var t=0;t