!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 e(){this._subscribers={}}function n(t){var e=t.split("|");return e[0]=e[0].split(","),{lng:parseFloat(e[0][0]),lat:parseFloat(e[0][1])}}function i(t,n){e.bind(this)(),this._options=n||{},this._data=[],t&&this.add(t)}function o(t,e,n){var i=60*n+30,o=Math.PI/180*i;return[t.x+e*Math.cos(o),t.y+e*Math.sin(o)]}function a(t,e){if("undefined"==typeof document);else{var n=document.createElement("canvas");t&&(n.width=t),e&&(n.height=e)}return n}function s(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 r(t,e,n){var i=h(n),o=l(n),a=i-o,s=0,r=1024;(p=n.range||null)&&2===p.length&&(s=(p[0]-o)/a*1024),p&&2===p.length&&(r=(p[1]-o)/a*1024);for(var u,c=n.maxOpacity||.8,v=n.minOpacity||0,p=n.range,d=3,g=t.length;dc&&(t[d]=256*c),t[d]/256=s&&u<=r?(t[d-3]=e[u],t[d-2]=e[u+1],t[d-1]=e[u+2]):t[d]=0}function h(t){return t.max||100}function l(t){return t.min||0}function u(t,e,n){var i=h(n),o=l(n),r=n._size;void 0==r&&void 0==(r=n.size)&&(r=13);var u=new s({gradient:n.gradient,max:i,min:o}),c=function(t){var e=t/2,n=t+e,i=new a(2*n,2*n),o=i.getContext("2d");return o.shadowBlur=e,o.shadowColor="black",o.shadowOffsetX=o.shadowOffsetY=1e4,o.beginPath(),o.arc(n-1e4,n-1e4,t,0,2*Math.PI,!0),o.closePath(),o.fill(),i}(r),v=c.width/2,p=c.height/2,d={};e.forEach(function(t,e){var n=void 0===t.count?1:t.count,o=Math.min(1,n/i).toFixed(2);d[o]=d[o]||[],d[o].push(t)});for(var g in d)if(!isNaN(g)){var f=d[g];t.beginPath(),n.withoutAlpha||(t.globalAlpha=g),t.strokeStyle=u.getColor(g*i),f.forEach(function(e,o){if(e.geometry){var a=e.geometry._coordinates||e.geometry.coordinates,s=e.geometry.type;if("Point"===s){r=void 0===e.count?1:e.count;t.globalAlpha=r/i,t.drawImage(c,a[0]-v,a[1]-p)}else if("LineString"===s){var r=void 0===e.count?1:e.count;t.globalAlpha=r/i,t.beginPath(),rt.draw(t,e,n),t.stroke()}}})}}function c(t,e,n){var i=60*n+30,o=Math.PI/180*i;return[t.x+e*Math.cos(o),t.y+e*Math.sin(o)]}function v(t,e,n){var i=t.createShader(n);return t.shaderSource(i,e),t.compileShader(i),i}function p(t,e,n){var i=v(t,e,t.VERTEX_SHADER),o=v(t,n,t.FRAGMENT_SHADER),a=t.createProgram();return t.attachShader(a,i),t.attachShader(a,o),t.linkProgram(a),t.useProgram(a),a}function d(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 g(t,e,n){n=n||2;var i=e&&e.length,o=i?e[0]*n:t.length,a=f(t,0,o,n,!0),s=[];if(!a)return s;var r,h,l,u,c,v,p;if(i&&(a=function(t,e,n,i){var o,a,s,r,h,l=[];for(o=0,a=e.length;o=i.next.y){var r=i.x+(a-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(r<=o&&r>s){if(s=r,r===o){if(a===i.y)return i;if(a===i.next.y)return i.next}n=i.x=i.x&&i.x>=u&&w(an.x)&&S(i,t)&&(n=i,v=h),i=i.next;return n}(t,e)){var n=C(e,t);y(n,n.next)}}(l[o],n),n=y(n,n.next);return n}(t,e,a,n)),t.length>80*n){r=l=t[0],h=u=t[1];for(var d=n;dl&&(l=c),v>u&&(u=v);p=Math.max(l-r,u-h)}return m(a,s,n,r,h,p),s}function f(t,e,n,i,o){var a,s;if(o===R(t,e,n,i)>0)for(a=e;a=e;a-=i)s=M(a,t[a],t[a+1],s);return s&&k(s,s.next)&&(z(s),s=s.next),s}function y(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!k(i,i.next)&&0!==b(i.prev,i,i.next))i=i.next;else{if(z(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function m(t,e,n,i,o,a,s){if(t){!s&&a&&function(t,e,n,i){var o=t;do{null===o.z&&(o.z=_(o.x,o.y,e,n,i)),o.prevZ=o.prev,o.nextZ=o.next,o=o.next}while(o!==t);o.prevZ.nextZ=null,o.prevZ=null,function(t){var e,n,i,o,a,s,r,h,l=1;do{for(n=t,t=null,a=null,s=0;n;){for(s++,i=n,r=0,e=0;e0||h>0&&i;)0===r?(o=i,i=i.nextZ,h--):0!==h&&i?n.z<=i.z?(o=n,n=n.nextZ,r--):(o=i,i=i.nextZ,h--):(o=n,n=n.nextZ,r--),a?a.nextZ=o:t=o,o.prevZ=a,a=o;n=i}a.nextZ=null,l*=2}while(s>1)}(o)}(t,i,o,a);for(var r,h,l=t;t.prev!==t.next;)if(r=t.prev,h=t.next,a?function(t,e,n,i){var o=t.prev,a=t,s=t.next;if(b(o,a,s)>=0)return!1;var r=o.xa.x?o.x>s.x?o.x:s.x:a.x>s.x?a.x:s.x,u=o.y>a.y?o.y>s.y?o.y:s.y:a.y>s.y?a.y:s.y,c=_(r,h,e,n,i),v=_(l,u,e,n,i),p=t.nextZ;for(;p&&p.z<=v;){if(p!==t.prev&&p!==t.next&&w(o.x,o.y,a.x,a.y,s.x,s.y,p.x,p.y)&&b(p.prev,p,p.next)>=0)return!1;p=p.nextZ}p=t.prevZ;for(;p&&p.z>=c;){if(p!==t.prev&&p!==t.next&&w(o.x,o.y,a.x,a.y,s.x,s.y,p.x,p.y)&&b(p.prev,p,p.next)>=0)return!1;p=p.prevZ}return!0}(t,i,o,a):function(t){var e=t.prev,n=t,i=t.next;if(b(e,n,i)>=0)return!1;var o=t.next.next;for(;o!==t.prev;){if(w(e.x,e.y,n.x,n.y,i.x,i.y,o.x,o.y)&&b(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}(t))e.push(r.i/n),e.push(t.i/n),e.push(h.i/n),z(t),t=h.next,l=h.next;else if((t=h)===l){s?1===s?m(t=function(t,e,n){var i=t;do{var o=i.prev,a=i.next.next;!k(o,a)&&E(o,i,i.next,a)&&S(o,a)&&S(a,o)&&(e.push(o.i/n),e.push(i.i/n),e.push(a.i/n),z(i),z(i.next),i=t=a),i=i.next}while(i!==t);return i}(t,e,n),e,n,i,o,a,2):2===s&&function(t,e,n,i,o,a){var s=t;do{for(var r=s.next.next;r!==s.prev;){if(s.i!==r.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&&E(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&S(t,e)&&S(e,t)&&function(t,e){var n=t,i=!1,o=(t.x+e.x)/2,a=(t.y+e.y)/2;do{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}while(n!==t);return i}(t,e)}(s,r)){var h=C(s,r);return s=y(s,s.next),h=y(h,h.next),m(s,e,n,i,o,a),void m(h,e,n,i,o,a)}r=r.next}s=s.next}while(s!==t)}(t,e,n,i,o,a):m(y(t),e,n,i,o,a,1);break}}}function x(t,e){return t.x-e.x}function _(t,e,n,i,o){return t=32767*(t-n)/o,e=32767*(e-i)/o,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function w(t,e,n,i,o,a,s,r){return(o-s)*(e-r)-(t-s)*(a-r)>=0&&(t-s)*(i-r)-(n-s)*(e-r)>=0&&(n-s)*(a-r)-(o-s)*(i-r)>=0}function b(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function k(t,e){return t.x===e.x&&t.y===e.y}function E(t,e,n,i){return!!(k(t,e)&&k(n,i)||k(t,i)&&k(n,e))||b(t,e,n)>0!=b(t,e,i)>0&&b(n,i,t)>0!=b(n,i,e)>0}function S(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function C(t,e){var n=new A(t.i,t.x,t.y),i=new A(e.i,e.x,e.y),o=t.next,a=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,i.next=n,n.prev=i,a.next=i,i.prev=a,i}function M(t,e,n,i){var o=new A(t,e,n);return i?(o.next=i.next,o.prev=i,i.next.prev=o,i.next=o):(o.prev=o,o.next=o),o}function z(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function A(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(t,e,n,i){for(var o=0,a=e,s=n-i;ay&&parseFloat(m-y)>180&&y<0&&(y=parseFloat(360+y),m=parseFloat(360+m));0,h=0,f==g?(i=0,o=y-m):m==y?(i=Math.PI/2,o=g-f):(i=Math.atan((f-g)/(m-y)),o=(f-g)/Math.sin(i));0==h&&(h=i+Math.PI/5);for(r=(a=o/2)*Math.cos(h)+y,s=a*Math.sin(h)+g,p=0;p0?x-360:x,_]),d+=1/n}return v}(t[i],t[i+1],e.count);o&&o.length>0&&(n=n.concat(o))}return n}function T(t){this.splitList=t||{other:1}}function D(t){this.splitList=t||[{start:0,value:"red"}]}function I(t){this.options=t||{},this.paneName=this.options.paneName||"mapPane",this.context=this.options.context||"2d",this.zIndex=this.options.zIndex||0,this.mixBlendMode=this.options.mixBlendMode||null,this.enableMassClear=this.options.enableMassClear,this._map=t.map,this._lastDrawTime=null,this.show()}function F(t,e){var n=e[0]-t[0],i=e[1]-t[1],o=360*Math.atan(i/n)/(2*Math.PI);return e[0]o&&i>a)return!0;return!1}(t[n],e))return!0;return!1}function U(t,e,n,i,o,a){if(!(o-i<=n)){var s=i+o>>1;Z(t,e,s,i,o,a%2),U(t,e,n,i,s-1,a+1),U(t,e,n,s+1,o,a+1)}}function Z(t,e,n,i,o,a){for(;o>i;){if(o-i>600){var s=o-i+1,r=n-i+1,h=Math.log(s),l=.5*Math.exp(2*h/3),u=.5*Math.sqrt(h*l*(s-l)/s)*(r-s/2<0?-1:1);Z(t,e,n,Math.max(i,Math.floor(n-r*l/s+u)),Math.min(o,Math.floor(n+(s-r)*l/s+u)),a)}var c=e[2*n+a],v=i,p=o;for(N(t,e,i,n),e[2*o+a]>c&&N(t,e,i,o);vc;)p--}e[2*i+a]===c?N(t,e,i,p):N(t,e,++p,o),p<=n&&(i=p+1),n<=p&&(o=p-1)}}function N(t,e,n,i){j(t,n,i),j(e,2*n,2*i),j(e,2*n+1,2*i+1)}function j(t,e,n){var i=t[e];t[e]=t[n],t[n]=i}function W(t,e,n,i){var o=t-n,a=e-i;return o*o+a*a}function H(t){return{type:"Feature",id:t.id,properties:q(t),geometry:{type:"Point",coordinates:[function(t){return 360*(t-.5)}(t.x),function(t){var e=(180-360*t)*Math.PI/180;return 360*Math.atan(Math.exp(e))/Math.PI-90}(t.y)]}}}function q(t){var e=t.numPoints,n=e>=1e4?Math.round(e/1e3)+"k":e>=1e3?Math.round(e/100)/10+"k":e;return Y(Y({},t.properties),{cluster:!0,cluster_id:t.id,point_count:e,point_count_abbreviated:n})}function V(t){return t/360+.5}function $(t){var e=Math.sin(t*Math.PI/180),n=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return n<0?0:n>1?1:n}function Y(t,e){for(var n in e)t[n]=e[n];return t}function G(t){return t.x}function J(t){return t.y}function Q(t){requestAnimationFrame(Q),St.update(t)}function X(t){function e(t,e){return function(){e.apply(t)}}this.isAdded_=!1,this.isAnimated_=!1,this.paneName_=X.DEFAULT_PANE_NAME_,this.updateHandler_=null,this.resizeHandler_=null,this.topLeft_=null,this.centerListener_=null,this.resizeListener_=null,this.needsResize_=!0,this.requestAnimationFrameId_=null;var n=document.createElement("canvas");n.style.position="absolute",n.style.top=0,n.style.left=0,n.style.pointerEvents="none",this.canvas=n,this.canvasCssWidth_=300,this.canvasCssHeight_=150,this.resolutionScale_=1,this.repositionFunction_=e(this,this.repositionCanvas_),this.resizeFunction_=e(this,this.resize_),this.requestUpdateFunction_=e(this,this.update_),t&&this.setOptions(t)}var K=function(t){t&&t.clearRect&&t.clearRect(0,0,t.canvas.width,t.canvas.height)};e.prototype.on=function(t,e){var n=this._subscribers[t];n||(n=[],this._subscribers[t]=n),n.push({callback:e})},e.prototype.off=function(t,e){var n=this._subscribers[t];if(n)for(var i=0;in&&(n=o)}return n}},i.prototype.getSum=function(t){var e=this._data;if(e&&!(e.length<=0)){for(var n=0,i=0;in&&(t=n),te&&(t=e),tn?o+(t-n)/(e-n)*(i-o):i},s.prototype.getLegend=function(t){var e=this.gradient,n=t.width||20,i=t.height||180,o=new a(n,i),s=o.getContext("2d"),r=s.createLinearGradient(0,i,0,0);for(var h in e)r.addColorStop(parseFloat(h),e[h]);return s.fillStyle=r,s.fillRect(0,0,n,i),o};var lt=("undefined"==typeof window?{}:window).devicePixelRatio||1,ut={draw:function(t,e,n){if(!(t.canvas.width<=0||t.canvas.height<=0)){var o=n.strength||.3;t.strokeStyle="rgba(0,0,0,"+o+")";var h=new a(t.canvas.width,t.canvas.height),l=h.getContext("2d");l.scale(lt,lt),n=n||{};var c=e instanceof i?e.get():e;t.save();var v=new s({gradient:n.gradient});if(u(l,c,n),!n.absolute){var p=l.getImageData(0,0,t.canvas.width,t.canvas.height);r(p.data,v.getImageData(),n),t.putImageData(p,0,0),t.restore()}v=null,h=null}}},ct={draw:function(t,e,n){t.save();var o=e instanceof i?e.get():e,a={},r=n._size||n.size||50,h=!("enableCluster"in n)||n.enableCluster,l=n.offset||{x:0,y:0},u=new s({min:n.min||0,max:n.max||100,gradient:n.gradient});if(h){for(var c=0;c1){var _=y-m,w=m+(yk*k+E*E&&(m=w+(1&f?1:-1)/2,f=b)}var L=m+"-"+f,S=v[L];S?S.push(o[p]):((S=v[L]=[o[p]]).i=m,S.j=f,S.x=(m+(1&f?.5:0))*l,S.y=f*u)}var C=new s({max:n.max||100,maxSize:h,gradient:n.gradient});for(var a in v){A=v[a];t.beginPath();for(var M=0;M<6;M++){var P=c({x:A.x+r.x,y:A.y+r.y},h,M);t.lineTo(P[0],P[1])}t.closePath();for(var z=0,p=0;p1||f<-1||f>1||(l.push(g,f),u++)}var y=new Float32Array(l),m=u,x=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,x),t.bufferData(t.ARRAY_BUFFER,y,t.STATIC_DRAW),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o),t.vertexAttrib1f(a,n._size);var _=d(n.fillStyle||"red");t.uniform4f(s,_[0]/255,_[1]/255,_[2]/255,_[3]/255),t.drawArrays(t.POINTS,0,m)}}};g.deviation=function(t,e,n,i){var o=e&&e.length,a=o?e[0]*n:t.length,s=Math.abs(R(t,0,a,n));if(o)for(var r=0,h=e.length;r0&&(i+=t[o-1].length,n.holes.push(i))}return n};var xt=["attribute vec4 a_Position;","void main() {","gl_Position = a_Position;","gl_PointSize = 30.0;","}"].join(""),_t=["precision mediump float;","uniform vec4 u_FragColor;","void main() {","gl_FragColor = u_FragColor;","}"].join(""),wt={draw:function(t,e,n){if(e){t.clear(t.COLOR_BUFFER_BIT),t.viewport(0,0,t.canvas.width,t.canvas.height);var i=p(t,xt,_t);t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE);var o=t.canvas.width/2,a=t.canvas.height/2;t.bindBuffer(t.ARRAY_BUFFER,t.createBuffer()),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,t.createBuffer());var s=t.getAttribLocation(i,"a_Position");t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(s);var r=t.getUniformLocation(i,"u_FragColor"),h=d(n.fillStyle||"red");t.uniform4f(r,h[0]/255,h[1]/255,h[2]/255,h[3]/255),t.lineWidth(n.lineWidth||1);for(var l=[],u=[],c=0,v=0,f=e.length;v65536&&(t.bufferData(t.ARRAY_BUFFER,new Float32Array(l),t.STATIC_DRAW),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array(u),t.STATIC_DRAW),t.drawElements(t.TRIANGLES,u.length,t.UNSIGNED_SHORT,0),l.length=0,u.length=0,c=0),_=0;_0&&("LineString"==o[0].geometry.type?gt.draw(t,o,n):"Polygon"==o[0].geometry.type||"MultiPolygon"==o[0].geometry.type?wt.draw(t,o,n):mt.draw(t,o,n))}},kt={getPoints:O};T.prototype.get=function(t){var e=this.splitList,n=e.other;for(var i in e)if(t==i){n=e[i];break}return n},T.prototype.generateByDataSet=function(t,e){var n=e||["rgba(255, 255, 0, 0.8)","rgba(253, 98, 104, 0.8)","rgba(255, 146, 149, 0.8)","rgba(255, 241, 193, 0.8)","rgba(110, 176, 253, 0.8)","rgba(52, 139, 251, 0.8)","rgba(17, 102, 252, 0.8)"],i=t.get();this.splitList={};for(var o=0,a=0;a=n.length-1));a++);this.splitList.other=n[n.length-1]},T.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},D.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&&t1?1:_);for(l in o)if(void 0!==i[l]){var b=i[l]||0,k=o[l];k instanceof Array?n[l]=d(k,w):("string"==typeof k&&(k="+"===k.charAt(0)||"-"===k.charAt(0)?b+parseFloat(k):parseFloat(k)),"number"==typeof k&&(n[l]=b+(k-b)*w))}if(null!==m&&m.call(n,w),1===_){if(r>0){isFinite(r)&&r--;for(l in a){if("string"==typeof o[l]&&(a[l]=a[l]+parseFloat(o[l])),h){var E=a[l];a[l]=o[l],o[l]=E}i[l]=a[l]}return h&&(u=!u),v=void 0!==e?t+e:t+c,!0}null!==x&&x.call(n,n);for(var L=0,S=g.length;L1?a(t[n],t[n-1],n-i):a(t[o],t[o+1>n?n:o+1],i-o)},Bezier:function(t,e){for(var n=0,i=t.length-1,o=Math.pow,a=St.Interpolation.Utils.Bernstein,s=0;s<=i;s++)n+=o(1-e,i-s)*o(e,s)*t[s]*a(i,s);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),a=St.Interpolation.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(i=n*(1+e))),a(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],i-o)):e<0?t[0]-(a(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(a(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):a(t[o?o-1:0],t[o],t[n1;i--)n*=i;return t[e]=n,n}}(),CatmullRom:function(t,e,n,i,o){var a=.5*(n-t),s=.5*(i-e),r=o*o;return(2*e-2*n+a+s)*(o*r)+(-3*e+3*n-2*a-s)*r+a*o+e}}};var Ct={},Mt={draw:function(t,e,n){var o="http://huiyan.baidu.com/github/tools/gis-drawing/static/images/direction.png";n.arrow&&n.arrow.url&&(o=n.arrow.url),Ct[o]||(Ct[o]=null);var a=Ct[o];if(!a){var s=Array.prototype.slice.call(arguments),r=new Image;return r.onload=function(){Ct[o]=r,Mt.draw.apply(null,s)},void(r.src=o)}var h=e instanceof i?e.get():e;t.save();for(var l in n)t[l]=n[l];for(var u=[],c=null,v=0,p=h.length;v=n&&r<=o&&h>=i&&h<=a&&u.push(t[d]);else{var g=Math.floor((p+v)/2);r=e[2*g],h=e[2*g+1],r>=n&&r<=o&&h>=i&&h<=a&&u.push(t[g]);var f=(c+1)%2;(0===c?n<=r:i<=h)&&(l.push(p),l.push(g-1),l.push(f)),(0===c?o>=r:a>=h)&&(l.push(g+1),l.push(v),l.push(f))}}return u}(this.ids,this.coords,t,e,n,i,this.nodeSize)},Dt.prototype.within=function(t,e,n){return function(t,e,n,i,o,a){for(var s=[0,t.length-1,0],r=[],h=o*o;s.length;){var l=s.pop(),u=s.pop(),c=s.pop();if(u-c<=a)for(var v=c;v<=u;v++)W(e[2*v],e[2*v+1],n,i)<=h&&r.push(t[v]);else{var p=Math.floor((c+u)/2),d=e[2*p],g=e[2*p+1];W(d,g,n,i)<=h&&r.push(t[p]);var f=(l+1)%2;(0===l?n-o<=d:i-o<=g)&&(s.push(c),s.push(p-1),s.push(f)),(0===l?n+o>=d:i+o>=g)&&(s.push(p+1),s.push(u),s.push(f))}}return r}(this.ids,this.coords,t,e,n,this.nodeSize)};var It={minZoom:0,maxZoom:16,radius:40,extent:512,nodeSize:64,log:!1,reduce:null,map:function(t){return t}},Ft=function(t){this.options=Y(Object.create(It),t),this.trees=new Array(this.options.maxZoom+1)};Ft.prototype.load=function(t){var e=this.options,n=(e.log,e.minZoom),i=e.maxZoom,o=e.nodeSize;t.length;this.points=t;for(var a=[],s=0;s=n;r--){Date.now();a=this._cluster(a,r),this.trees[r]=new Dt(a,G,J,o,Float32Array)}return this},Ft.prototype.getClusters=function(t,e){var n=((t[0]+180)%360+360)%360-180,i=Math.max(-90,Math.min(90,t[1])),o=180===t[2]?180:((t[2]+180)%360+360)%360-180,a=Math.max(-90,Math.min(90,t[3]));if(t[2]-t[0]>=360)n=-180,o=180;else if(n>o){var s=this.getClusters([n,i,180,a],e),r=this.getClusters([-180,i,o,a],e);return s.concat(r)}for(var h=this.trees[this._limitZoom(e)],l=[],u=0,c=h.range(V(n),$(a),V(o),$(i));u>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 s=this.options.radius/(this.options.extent*Math.pow(2,n-1)),r=[],h=0,l=o.within(a.x,a.y,s);h1?this._map(l,!0):null,f=(h<<5)+(e+1),y=0,m=c;y-1){if(t.isPointInStroke&&t.isPointInStroke(a,s))return n[i]}else if(t.isPointInPath(a,s))return n[i]}}},{key:"clickEvent",value:function(t,e){if(this.options.methods){var n=this.isPointInPath(this.getContext(),t);n?this.options.methods.click(n,e):this.options.methods.click(null,e)}}},{key:"mousemoveEvent",value:function(t,e){if(this.options.methods){var n=this.isPointInPath(this.getContext(),t);n?this.options.methods.mousemove(n,e):this.options.methods.mousemove(null,e)}}},{key:"tapEvent",value:function(t,e){if(this.options.methods){var n=this.isPointInPath(this.getContext(),t);n?this.options.methods.tap(n,e):this.options.methods.tap(null,e)}}},{key:"update",value:function(t,e){var n=t.options,i=this.options;for(var o in n)i[o]=n[o];this.init(i),!1!==e&&this.draw()}},{key:"setOptions",value:function(t){this.dataSet.reset(),this.init(t),this.draw()}},{key:"set",value:function(t){var e=this.getContext(),n=this.getDefaultContextConfig();for(var i in n)e[i]=n[i];this.init(t.options),this.draw()}},{key:"destroy",value:function(){this.unbindEvent(),this.hide()}},{key:"initAnimator",value:function(){var t=this,e=t.options.animation;if("time"==t.options.draw||t.isEnabledTime()){e.stepsRange||(e.stepsRange={start:this.dataSet.getMin("time")||0,end:this.dataSet.getMax("time")||0}),this.steps={step:e.stepsRange.start},t.animator=new St.Tween(this.steps).onUpdate(function(){t._canvasUpdate(this.step)}).repeat(1/0),this.addAnimatorEvent();var n=1e3*e.duration||5e3;t.animator.to({step:e.stepsRange.end},n),t.animator.start()}else t.animator&&t.animator.stop()}},{key:"addAnimatorEvent",value:function(){}},{key:"animatorMovestartEvent",value:function(){var t=this.options.animation;this.isEnabledTime()&&this.animator&&(this.steps.step=t.stepsRange.start,this.animator.stop())}},{key:"animatorMoveendEvent",value:function(){this.isEnabledTime()&&this.animator&&this.animator.start()}}]),t}(),Ut=function(t){function e(t,n,i){nt(this,e);var o=st(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i));o.map=t,o.options=i||{},o.dataSet=n;var a=new I({map:t,zIndex:o.options.zIndex,update:o._canvasUpdate.bind(o)});o.init(o.options),o.canvasLayer=a,o.transferToMercator();var s=o;return n.on("change",function(){s.transferToMercator(),a.draw()}),o.ctx=a.canvas.getContext("2d"),o.start(),o}return at(e,Bt),it(e,[{key:"draw",value:function(){this.canvasLayer.draw()}},{key:"init",value:function(t){this.options=t,this.initDataRange(t),this.context=this.options.context||"2d",this.options.zIndex&&this.canvasLayer&&this.canvasLayer.setZIndex(this.options.zIndex),this.options.max&&this.intensity.setMax(this.options.max),this.options.min&&this.intensity.setMin(this.options.min),this.initAnimator()}},{key:"transferToMercator",value:function(){var t=this.map.getMapType().getProjection();if("bd09mc"!==this.options.coordType){var e=this.dataSet.get();e=this.dataSet.transferCoordinate(e,function(e){var n=t.lngLatToPoint({lng:e[0],lat:e[1]});return[n.x,n.y]},"coordinates","coordinates_mercator"),this.dataSet._set(e)}}},{key:"_canvasUpdate",value:function(){var t=this.ctx;if(t){var e,n=this.map,i=n.getMapType().getProjection();e=i.getZoomUnits?i.getZoomUnits(n.getZoom()):Math.pow(2,18-n.getZoom());var o=i.lngLatToPoint(n.getCenter()),a=new BMap.Pixel(o.x-n.getSize().width/2*e,o.y+n.getSize().height/2*e);K(t);var s={fromColumn:"bd09mc"==this.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){if(t){return[(t[0]-a.x)/e,(a.y-t[1])/e]}}};this.data=this.dataSet.get(s),this.processData(this.data),this.drawAnimation()}}},{key:"drawAnimation",value:function(){var t=this.ctx,e=this.data;if(e){t.save(),t.globalCompositeOperation="destination-out",t.fillStyle="rgba(0, 0, 0, .1)",t.fillRect(0,0,t.canvas.width,t.canvas.height),t.restore(),t.save(),this.options.shadowColor&&(t.shadowColor=this.options.shadowColor),this.options.shadowBlur&&(t.shadowBlur=this.options.shadowBlur),this.options.globalAlpha&&(t.globalAlpha=this.options.globalAlpha),this.options.globalCompositeOperation&&(t.globalCompositeOperation=this.options.globalCompositeOperation);for(var n=this.options,i=0;io&&(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 s=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 r=e[i]._index;t.arc(e[i].geometry._coordinates[r][0],e[i].geometry._coordinates[r][1],s,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}}]),e}(),Zt=function(t){function e(t,n,i){nt(this,e);var o=st(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i)),a=o;i=i||{},o.clickEvent=o.clickEvent.bind(o),o.mousemoveEvent=o.mousemoveEvent.bind(o),o.tapEvent=o.tapEvent.bind(o),a.init(i),a.argCheck(i),a.transferToMercator();var s=o.canvasLayer=new I({map:t,context:o.context,paneName:i.paneName,mixBlendMode:i.mixBlendMode,enableMassClear:i.enableMassClear,zIndex:i.zIndex,update:function(){a._canvasUpdate()}});return n.on("change",function(){a.transferToMercator(),s.draw()}),o}return at(e,Bt),it(e,[{key:"clickEvent",value:function(t){var n=t.pixel;ot(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"clickEvent",this).call(this,n,t)}},{key:"mousemoveEvent",value:function(t){var n=t.pixel;ot(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"mousemoveEvent",this).call(this,n,t)}},{key:"tapEvent",value:function(t){var n=t.pixel;ot(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"tapEvent",this).call(this,n,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 e,n=this.map,i=n.getMapType();if(e=i.getProjection?i.getProjection():{lngLatToPoint:function(t){var e=n.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||t[0]>180||t[1]<-90||t[1]>90)return t;var n=e.lngLatToPoint({lng:t[0],lat:t[1]});return[n.x,n.y]},"coordinates","coordinates_mercator"),t._set(o)}}},{key:"getContext",value:function(){return this.canvasLayer.canvas.getContext(this.context)}},{key:"_canvasUpdate",value:function(t){if(this.canvasLayer){var e,n,i=this.options.animation,o=this.canvasLayer._map;o.getMapType().getProjection?n=(e=o.getMapType().getProjection()).lngLatToPoint(o.getCenter()):(n={x:o.getCenter().lng,y:o.getCenter().lat},e={lngLatToPoint:function(t){var e=o.lnglatToMercator(t.lng,t.lat);return{x:e[0],y:e[1]}}});var a;a=e.getZoomUnits?e.getZoomUnits(o.getZoom()):Math.pow(2,18-o.getZoom());var s=new BMap.Pixel(n.x-o.getSize().width/2*a,n.y+o.getSize().height/2*a),r=this.getContext();if(this.isEnabledTime()){if(void 0===t)return void K(r);"2d"==this.context&&(r.save(),r.globalCompositeOperation="destination-out",r.fillStyle="rgba(0, 0, 0, .1)",r.fillRect(0,0,r.canvas.width,r.canvas.height),r.restore())}else K(r);if("2d"==this.context)for(var h in this.options)r[h]=this.options[h];else r.clear(r.COLOR_BUFFER_BIT);if(!(this.options.minZoom&&o.getZoom()this.options.maxZoom)){var l=1;"2d"!=this.context&&(l=this.canvasLayer.devicePixelRatio);var u={fromColumn:"bd09mc"==this.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-s.x)/a*l,(s.y-t[1])/a*l]}};void 0!==t&&(u.filter=function(e){var n=i.trails||10;return!!(t&&e.time>t-n&&e.timethis.options.maxZoom)){r=1;"2d"!=this.context&&(r=this.canvasLayer.devicePixelRatio);var a=this.map,s=a.getProjection(),r=Math.pow(2,a.zoom)*resolutionScale,h=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)*r,y:(n.y-h.y)*r};return[i.x,i.y]}};void 0!==t&&(l.filter=function(n){var i=e.trails||10;return!!(t&&n.time>t-i&&n.timee-n&&t.time0&&void 0!==arguments[0]?arguments[0]:null,n=arguments[1],i=arguments[2];nt(this,e);var o=st(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i));return o.options=i,o.canvasLayer={canvas:null,devicePixelRatio:window.devicePixelRatio},o.layer_=null,o.initDataRange(i),o.initAnimator(),o.onEvents(),t.on("complete",function(){this.init(t,i),this.argCheck(i)},o),o}return at(e,Bt),it(e,[{key:"init",value:function(t,e){if(!t)throw new Error("not map object");this.map=t,this.context=this.options.context||"2d",this.getCanvasLayer()}},{key:"_canvasUpdate",value:function(t){this.render(this.canvasLayer.canvas,t)}},{key:"render",value:function(t,e){if(t){var n=this.map,o=t.getContext(this.context),a=this.options.animation;if(this.isEnabledTime()){if(void 0===e)return K(o),this;"2d"===this.context&&(o.save(),o.globalCompositeOperation="destination-out",o.fillStyle="rgba(0, 0, 0, .1)",o.fillRect(0,0,o.canvas.width,o.canvas.height),o.restore())}else K(o);if("2d"===this.context)for(var s in this.options)o[s]=this.options[s];else o.clear(o.COLOR_BUFFER_BIT);var r={transferCoordinate:function(t){var e=n.lngLatToContainer(new AMap.LngLat(t[0],t[1]));return[e.x,e.y]}};void 0!==e&&(r.filter=function(t){var n=a.trails||10;return!!(e&&t.time>e-n&&t.time0&&void 0!==arguments[0]?arguments[0]:null,n=arguments[1],i=arguments[2];nt(this,e);var o=st(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i));return o.options=i,o.canvasLayer={canvas:null,devicePixelRatio:window.devicePixelRatio},o.layer_=null,o.previousCursor_=void 0,o.init(t,i),o.argCheck(i),o}return at(e,Bt),it(e,[{key:"init",value:function(t,e){if(!(t&&t instanceof ol.Map))throw new Error("not map object");this.$Map=t,this.context=this.options.context||"2d",this.getCanvasLayer(),this.initDataRange(e),this.initAnimator(),this.onEvents()}},{key:"_canvasUpdate",value:function(t){this.render(this.canvasLayer.canvas,t)}},{key:"render",value:function(t,e){var n=this.$Map,o=t.getContext(this.context),a=this.options.animation,s=this.options.hasOwnProperty("projection")?this.options.projection:"EPSG:4326";if(this.isEnabledTime()){if(void 0===e)return K(o),this;"2d"===this.context&&(o.save(),o.globalCompositeOperation="destination-out",o.fillStyle="rgba(0, 0, 0, .1)",o.fillRect(0,0,o.canvas.width,o.canvas.height),o.restore())}else K(o);if("2d"===this.context)for(var r in this.options)o[r]=this.options[r];else o.clear(o.COLOR_BUFFER_BIT);var h={transferCoordinate:function(t){return n.getPixelFromCoordinate(ol.proj.transform(t,s,"EPSG:4326"))}};void 0!==e&&(h.filter=function(t){var n=a.trails||10;return!!(e&&t.time>e-n&&t.timee.options.maxZoom)){var s=o.getBounds(),r=s.getEast()-s.getWest(),h=s.getNorth()-s.getSouth(),l=o.getSize(),u=r/l.x,c=h/l.y,v=this.canvasLayer.getTopLeft(),p=o.latLngToContainerPoint(v),d={transferCoordinate:function(t){var n,i={x:(n="2d"===e.context?o.latLngToContainerPoint(L.latLng(t[1],t[0])):{x:(t[0]-v.lng)/u,y:(v.lat-t[1])/c}).x-p.x,y:n.y-p.y};return[i.x,i.y]}};void 0!==t&&(d.filter=function(e){var i=n.trails||10;return t&&e.time>t-i&&e.timet-n&&e.timeS||Math.abs(r.y)>S){var h=1/Math.pow(n({source:y[a[s]][e],target:y[t][e]}),1);o.x+=r.x*h,o.y+=r.y*h}}return o}function l(t,n,i){for(var o=m/(e(g[t])*(n+1)),a=[{x:0,y:0}],s=1;ss;){var u=s/l,c=y[e][h-1].x,v=y[e][h-1].y;c+=u*(y[e][h].x-y[e][h-1].x),v+=u*(y[e][h].y-y[e][h-1].y),r.push({x:c,y:v}),l-=s,s=n}s-=l}r.push(d[g[e].target]),y[e]=r}}function c(t,e){var n=s(d[e.source],{source:d[t.source],target:d[t.target]}),i=s(d[e.target],{source:d[t.source],target:d[t.target]}),o={x:(n.x+i.x)/2,y:(n.y+i.y)/2},r={x:(d[t.source].x+d[t.target].x)/2,y:(d[t.source].y+d[t.target].y)/2};return Math.max(0,1-2*a(r,o)/a(n,i))}function v(n,i){return function(n,i){return Math.abs(function(t,e){return t.x*e.x+t.y*e.y}(t(n),t(i))/(e(n)*e(i)))}(n,i)*function(t,n){var i=(e(t)+e(n))/2;return 2/(i/Math.min(e(t),e(n))+Math.max(e(t),e(n))/i)}(n,i)*function(t,n){var i=(e(t)+e(n))/2;return i/(i+a({x:(d[t.source].x+d[t.target].x)/2,y:(d[t.source].y+d[t.target].y)/2},{x:(d[n.source].x+d[n.target].x)/2,y:(d[n.source].y+d[n.target].y)/2}))}(n,i)*function(t,e){return Math.min(c(t,e),c(e,t))}(n,i)}function p(t,e){return v(t,e)>=L}var d={},g=[],f=[],y=[],m=.1,x=.1,_=1,w=2,b=6,k=70,E=.6666667,L=.6,S=1e-8,C=function(){var t=x,e=k,n=_;!function(){for(var t=0;t