!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";function m(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[v]=256*l),t[v]/25680*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),v=q(l,u,e,n,i),p=t.nextZ;p&&p.z<=v;){if(p!==t.prev&&p!==t.next&&$(o.x,o.y,a.x,a.y,r.x,r.y,p.x,p.y)&&0<=G(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&&$(o.x,o.y,a.x,a.y,r.x,r.y,p.x,p.y)&&0<=G(p.prev,p,p.next))return!1;p=p.prevZ}return!0}function j(t,e,n){var i=t;do{var o=i.prev,a=i.next.next;!Y(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 N(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,v=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'+o+"";return n.innerHTML=i,n},ut.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&&Mt(e,n,o,a);gd;)f--}n[2*o+r]===d?Mt(e,n,o,f):Mt(e,n,++f,a),f<=i&&(o=f+1),i<=f&&(a=f-1)}}(t,e,r,i,o,a%2),Ct(t,e,n,i,r-1,a+1),Ct(t,e,n,1+r,o,a+1)}}function Mt(t,e,n,i){Pt(t,n,i),Pt(e,2*n,2*i),Pt(e,2*n+1,2*i+1)}function Pt(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function zt(t,e,n,i){var o=t-n,a=e-i;return o*o+a*a}function At(t){return t[0]}function Rt(t){return t[1]}function Ot(t,e,n,i,o){void 0===e&&(e=At),void 0===n&&(n=Rt),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()}},{key:"clearData",value:function(){this.dataSet&&this.dataSet.clear(),this.update({options:null})}},{key:"destroy",value:function(){this.stop(),this.unbindEvent(),this.clearData(),this.map.removeOverlay(this.canvasLayer),this.canvasLayer=null}}]),Gt);function Gt(t,e,n){s(this,Gt);var i=u(this,(Gt.__proto__||Object.getPrototypeOf(Gt)).call(this,t,e,n));i.map=t,i.options=n||{},i.dataSet=e;var o=new pt({map:t,zIndex:i.options.zIndex,update:i._canvasUpdate.bind(i)});i.init(i.options),i.canvasLayer=o,i.transferToMercator();var a=i;return e.on("change",function(){a.transferToMercator(),o.draw()}),i.ctx=o.canvas.getContext("2d"),i.start(),i}var Yt="undefined"==typeof window?{}:window,Jt=Yt.BMap||Yt.BMapGL,Qt=(l(Xt,Wt),e(Xt,[{key:"clickEvent",value:function(t){var e=t.pixel;h(Xt.prototype.__proto__||Object.getPrototypeOf(Xt.prototype),"clickEvent",this).call(this,e,t)}},{key:"mousemoveEvent",value:function(t){var e=t.pixel;h(Xt.prototype.__proto__||Object.getPrototypeOf(Xt.prototype),"mousemoveEvent",this).call(this,e,t)}},{key:"tapEvent",value:function(t){var e=t.pixel;h(Xt.prototype.__proto__||Object.getPrototypeOf(Xt.prototype),"tapEvent",this).call(this,e,t)}},{key:"bindEvent",value:function(){this.unbindEvent();var t=this.map,e=0,n=this;this.options.methods&&(this.options.methods.click&&(t.setDefaultCursor("default"),t.addEventListener("click",this.clickEvent)),this.options.methods.mousemove&&t.addEventListener("mousemove",this.mousemoveEvent),"ontouchend"in window.document&&this.options.methods.tap&&(t.addEventListener("touchstart",function(t){e=new Date}),t.addEventListener("touchend",function(t){new Date-e<300&&n.tapEvent(t)})))}},{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(t){t=t||this.dataSet;var n,i=this.map,e=i.getMapType();if(n=e.getProjection?e.getProjection():{lngLatToPoint:function(t){var e=i.lnglatToMercator(t.lng,t.lat);return{x:e[0],y:e[1]}}},"bd09mc"!==this.options.coordType){var o=t.get();o=t.transferCoordinate(o,function(t){if(t[0]<-180||180o.options.maxZoom)){var u=1;"2d"!=this.context&&(u=this.canvasLayer.devicePixelRatio);var c,v={fromColumn:"bd09mc"==o.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-s.x)/i*u,(s.y-t[1])/i*u]}};if(void 0!==n&&(v.filter=function(t){var e=a.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,v=this.canvasLayer.getTopLeft(),p=a.latLngToContainerPoint(v),d={transferCoordinate:function(t){var e,n={x:(e="2d"===i.context?a.latLngToContainerPoint(L.latLng(t[1],t[0])):{x:(t[0]-v.lng)/u,y:(v.lat-t[1])/c}).x-p.x,y:e.y-p.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.timeh||Math.abs(r.y)>h){var s=1/Math.pow((n={source:m[o[a]][e],target:m[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+=r.x*s,i.y+=r.y*s}}return i}function L(t,e,n){for(var i,o,a,r,s,h,l,u,c=x/(_(y[t])*(e+1)),v=[{x:0,y:0}],p=1;p=g&&(l[t].push(e),l[e].push(t)));var n,i}();for(var i=0;i