!function(t,e){"object"==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";var m=function(t){t&&t.clearRect&&t.clearRect(0,0,t.canvas.width,t.canvas.height)};function n(){this._subscribers={}}n.prototype.on=function(t,e){var n=this._subscribers[t];n||(n=[],this._subscribers[t]=n),n.push({callback:e})},n.prototype.off=function(t,e){var n=this._subscribers[t];if(n)for(var i=0;il&&(t[c]=256*l),h&&r<=h&&h<=s?(t[c-3]=e[h],t[c-2]=e[1+h],t[c-1]=e[2+h]):t[c]=0}(h.data,s.getImageData(),n),t.putImageData(h,0,0),t.restore()}o=s=null}}},w={draw:function(t,e,n){t.save();for(var i=e instanceof T?e.get():e,o={},a=n._size||n.size||50,r=n.offset||{x:0,y:0},s=0;s80*n){i=a=t[0],o=r=t[1];for(var d=n;da.x?o.x>r.x?o.x:r.x:a.x>r.x?a.x:r.x,u=o.y>a.y?o.y>r.y?o.y:r.y:a.y>r.y?a.y:r.y,c=q(s,h,e,n,i),p=q(l,u,e,n,i),v=t.nextZ;v&&v.z<=p;){if(v!==t.prev&&v!==t.next&&$(o.x,o.y,a.x,a.y,r.x,r.y,v.x,v.y)&&0<=Y(v.prev,v,v.next))return!1;v=v.nextZ}for(v=t.prevZ;v&&v.z>=c;){if(v!==t.prev&&v!==t.next&&$(o.x,o.y,a.x,a.y,r.x,r.y,v.x,v.y)&&0<=Y(v.prev,v,v.next))return!1;v=v.prevZ}return!0}function N(t,e,n){var i=t;do{var o=i.prev,a=i.next.next;!G(o,a)&&J(o,i,i.next,a)&&Q(o,a)&&Q(a,o)&&(e.push(o.i/n),e.push(i.i/n),e.push(a.i/n),tt(i),tt(i.next),i=t=a),i=i.next}while(i!==t);return i}function j(t,e,n,i,o,a){var r,s,h=t;do{for(var l=h.next.next;l!==h.prev;){if(h.i!==l.i&&(s=l,(r=h).next.i!==s.i&&r.prev.i!==s.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&&J(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(r,s)&&Q(r,s)&&Q(s,r)&&function(t,e){var n=t,i=!1,o=(t.x+e.x)/2,a=(t.y+e.y)/2;for(;n.y>a!=n.next.y>a&&o<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next,n!==t;);return i}(r,s))){var u=X(h,l);return h=F(h,h.next),u=F(u,u.next),B(h,e,n,i,o,a),void B(u,e,n,i,o,a)}l=l.next}h=h.next}while(h!==t)}function W(t,e){return t.x-e.x}function H(t,e){if(e=function(t,e){var n,i=e,o=t.x,a=t.y,r=-1/0;do{if(a<=i.y&&a>=i.next.y){var s=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(s<=o&&r=i.x&&i.x>=u&&$(an.x)&&Q(i,t)&&(n=i,p=h),i=i.next;return n}(t,e)){var n=X(e,t);F(n,n.next)}}function q(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 V(t){for(var e=t,n=t;e.x=n.length-1));a++);this.splitList.other=n[n.length-1]},ht.prototype.getLegend=function(t){var e=this.splitList,n=document.createElement("div");n.style.cssText="background:#fff; padding: 5px; border: 1px solid #ccc;";var i="";for(var o in e)i+='
'+o+"
";return n.innerHTML=i,n},lt.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&&t>1;!function t(e,n,i,o,a,r){for(;od&&Lt(e,n,o,a);gd;)f--}n[2*o+r]===d?Lt(e,n,o,f):Lt(e,n,++f,a),f<=i&&(o=f+1),i<=f&&(a=f-1)}}(t,e,r,i,o,a%2),Et(t,e,n,i,r-1,a+1),Et(t,e,n,1+r,o,a+1)}}function Lt(t,e,n,i){St(t,n,i),St(e,2*n,2*i),St(e,2*n+1,2*i+1)}function St(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function Ct(t,e,n,i){var o=t-n,a=e-i;return o*o+a*a}var Mt=function(t){return t[0]},Pt=function(t){return t[1]},zt=function(t,e,n,i,o){void 0===e&&(e=Mt),void 0===n&&(n=Pt),void 0===i&&(i=64),void 0===o&&(o=Float64Array),this.nodeSize=i;for(var a=(this.points=t).length<65536?Uint16Array:Uint32Array,r=this.ids=new a(t.length),s=this.coords=new o(2*t.length),h=0;h>5,n=t%32,i="No cluster with the specified id.",o=this.trees[n];if(!o)throw new Error(i);var a=o.points[e];if(!a)throw new Error(i);for(var r=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=[],h=0,l=o.within(a.x,a.y,r);ho&&(e[i]._size=a),t.lineWidth=1,t.strokeStyle=e[i].strokeStyle||e[i]._strokeStyle||n.strokeStyle||"yellow",t.stroke(),(l=e[i].fillStyle||e[i]._fillStyle||n.fillStyle)&&(t.fillStyle=l,t.fill())}else if("LineString"===e[i].geometry.type){t.beginPath();var r=e[i].size||this.options.size||5;a=e[i].minSize||this.options.minSize||0;void 0===e[i]._index&&(e[i]._index=0);var s=e[i]._index;t.arc(e[i].geometry._coordinates[s][0],e[i].geometry._coordinates[s][1],r,0,2*Math.PI,!0),t.closePath(),e[i]._index++,e[i]._index>=e[i].geometry._coordinates.length&&(e[i]._index=0);var h=e[i].strokeStyle||n.strokeStyle,l=e[i].fillStyle||n.fillStyle||"yellow";t.fillStyle=l,t.fill(),h&&n.lineWidth&&(t.lineWidth=n.lineWidth||1,t.strokeStyle=h,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()}}]),r}(),jt=function(t){function r(t,e,n){s(this,r);var i=c(this,(r.__proto__||Object.getPrototypeOf(r)).call(this,t,e,n)),o=i;n=n||{},i.clickEvent=i.clickEvent.bind(i),i.mousemoveEvent=i.mousemoveEvent.bind(i),i.tapEvent=i.tapEvent.bind(i),o.init(n),o.argCheck(n),o.transferToMercator();var a=i.canvasLayer=new ct({map:t,context:i.context,paneName:n.paneName,mixBlendMode:n.mixBlendMode,enableMassClear:n.enableMassClear,zIndex:n.zIndex,update:function(){o._canvasUpdate()}});return e.on("change",function(){o.transferToMercator(),a.draw()}),i}return u(r,Zt),h(r,[{key:"clickEvent",value:function(t){var e=t.pixel;l(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"clickEvent",this).call(this,e,t)}},{key:"mousemoveEvent",value:function(t){var e=t.pixel;l(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"mousemoveEvent",this).call(this,e,t)}},{key:"tapEvent",value:function(t){var e=t.pixel;l(r.prototype.__proto__||Object.getPrototypeOf(r.prototype),"tapEvent",this).call(this,e,t)}},{key:"bindEvent",value:function(t){this.unbindEvent();var e=this.map,n=0,i=this;this.options.methods&&(this.options.methods.click&&(e.setDefaultCursor("default"),e.addEventListener("click",this.clickEvent)),this.options.methods.mousemove&&e.addEventListener("mousemove",this.mousemoveEvent),"ontouchend"in window.document&&this.options.methods.tap&&(e.addEventListener("touchstart",function(t){n=new Date}),e.addEventListener("touchend",function(t){new Date-n<300&&i.tapEvent(t)})))}},{key:"unbindEvent",value:function(t){var e=this.map;this.options.methods&&(this.options.methods.click&&e.removeEventListener("click",this.clickEvent),this.options.methods.mousemove&&e.removeEventListener("mousemove",this.mousemoveEvent))}},{key:"transferToMercator",value:function(t){t||(t=this.dataSet);var n=this.map.getMapType().getProjection();if("bd09mc"!==this.options.coordType){var e=t.get();e=t.transferCoordinate(e,function(t){if(t[0]<-180||180t.options.maxZoom)){var l=1;"2d"!=this.context&&(l=this.canvasLayer.devicePixelRatio);var u,c={fromColumn:"bd09mc"==t.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-r.x)/o*l,(r.y-t[1])/o*l]}};if(void 0!==n&&(c.filter=function(t){var e=i.trails||10;return!!(n&&t.time>n-e&&t.timet.options.maxZoom)){var a=1;"2d"!=this.context&&(a=this.canvasLayer.devicePixelRatio);var r=this.map,s=r.getProjection(),h=(a=Math.pow(2,r.zoom)*resolutionScale,s.fromLatLngToPoint(this.canvasLayer.getTopLeft())),l={transferCoordinate:function(t){var e=new google.maps.LatLng(t[1],t[0]),n=s.fromLatLngToPoint(e),i={x:(n.x-h.x)*a,y:(n.y-h.y)*a};return[i.x,i.y]}};void 0!==n&&(l.filter=function(t){var e=i.trails||10;return!!(n&&t.time>n-e&&t.timen-e&&t.timen-e&&t.timen-e&&t.timei.options.maxZoom)){var r=a.getBounds(),s=r.getEast()-r.getWest(),h=r.getNorth()-r.getSouth(),l=a.getSize(),u=s/l.x,c=h/l.y,p=this.canvasLayer.getTopLeft(),v=a.latLngToContainerPoint(p),d={transferCoordinate:function(t){var e,n={x:(e="2d"===i.context?a.latLngToContainerPoint(L.latLng(t[1],t[0])):{x:(t[0]-p.lng)/u,y:(p.lat-t[1])/c}).x-v.x,y:e.y-v.y};return[n.x,n.y]}};void 0!==n&&(d.filter=function(t){var e=o.trails||10;return n&&t.time>n-e&&t.timen-e&&t.timef||Math.abs(s.y)>f){var h=1/Math.pow((i={source:y[a[r]][e],target:y[t][e]},Math.sqrt(Math.pow(i.source.x-i.target.x,2)+Math.pow(i.source.y-i.target.y,2))),1);o.x+=s.x*h,o.y+=s.y*h}}return o}function E(t,e,n){for(var i,o,a,r,s,h,l,u,c=x/(_(m[t])*(e+1)),p=[{x:0,y:0}],v=1;v=g&&(l[t].push(e),l[e].push(t)));var n,i}();for(var i=0;i