From 1d20e6cb6dc5453f9c46f5d9ce960c8d26addd1c Mon Sep 17 00:00:00 2001 From: nikai Date: Mon, 14 Jan 2019 17:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=A6=86=E7=9B=96=E7=89=A9zIndex=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/dist/react-bmap.min.js | 2 +- docs/examples/build/app.js | 1686 ++++++++++++++++++++++++++++------ package.json | 2 +- src/components/marker.js | 5 +- src/components/marker.md | 1 + src/overlay/CustomOverlay.js | 12 +- 6 files changed, 1440 insertions(+), 268 deletions(-) diff --git a/docs/dist/react-bmap.min.js b/docs/dist/react-bmap.min.js index af9690b..1e286fd 100644 --- a/docs/dist/react-bmap.min.js +++ b/docs/dist/react-bmap.min.js @@ -1 +1 @@ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],e):"object"==typeof exports?exports.ReactBMap=e(require("react"),require("react-dom")):t.ReactBMap=e(t.React,t.ReactDOM)}("undefined"!=typeof self?self:this,function(t,e){return function(t){function e(o){if(n[o])return n[o].exports;var i=n[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,e),i.l=!0,i.exports}var n={};return e.m=t,e.c=n,e.d=function(t,n,o){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:o})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=9)}([function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;ni&&(t[r]=256*i),t[r-3]=e[o],t[r-2]=e[o+1],t[r-1]=e[o+2]}function c(t,e,n){var o=n.max||100,i=n.min||0,r=n._size;void 0==r&&void 0==(r=n.size)&&(r=13);var a=new l({gradient:n.gradient,max:o,min:i}),s=u(r),p=s.width/2,c=s.height/2,f=e,h={};f.forEach(function(t,e){var n=void 0===t.count?1:t.count,i=Math.min(1,n/o).toFixed(2);h[i]=h[i]||[],h[i].push(t)});for(var d in h)if(!isNaN(d)){var y=h[d];t.beginPath(),n.withoutAlpha||(t.globalAlpha=d),t.strokeStyle=a.getColor(d*o),y.forEach(function(e,i){if(e.geometry){var r=e.geometry._coordinates||e.geometry.coordinates,a=e.geometry.type;if("Point"===a){var l=void 0===e.count?1:e.count;t.globalAlpha=l/o,t.drawImage(s,r[0]-p,r[1]-c)}else if("LineString"===a){var l=void 0===e.count?1:e.count;t.globalAlpha=l/o,t.beginPath(),dt.draw(t,e,n),t.stroke()}}})}}function f(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 r=new s(t.canvas.width,t.canvas.height),a=r.getContext("2d");a.scale(vt,vt),n=n||{};var u=e instanceof i?e.get():e;t.save();var f=new l({gradient:n.gradient});if(c(a,u,n),!n.absolute){var h=a.getImageData(0,0,t.canvas.width,t.canvas.height);p(h.data,f.getImageData(),n),t.putImageData(h,0,0),t.restore()}f=null,r=null}}function h(t,e,n){var o=60*n+30,i=Math.PI/180*o;return[t.x+e*Math.cos(i),t.y+e*Math.sin(i)]}function d(t,e,n){var o=t.createShader(n);return t.shaderSource(o,e),t.compileShader(o),o}function y(t,e,n){var o=d(t,e,t.VERTEX_SHADER),i=d(t,n,t.FRAGMENT_SHADER),r=t.createProgram();return t.attachShader(r,o),t.attachShader(r,i),t.linkProgram(r),t.useProgram(r),r}function g(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 v(t,e,n){if(e){var o=y(t,_t,xt);t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE),t.clear(t.COLOR_BUFFER_BIT);var i=t.canvas.width/2,r=t.canvas.height/2,a=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,a);var s=t.getAttribLocation(o,"a_Position");t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(s);var l=t.getUniformLocation(o,"u_FragColor"),u=g(n.strokeStyle||"red");t.uniform4f(l,u[0]/255,u[1]/255,u[2]/255,u[3]/255),t.lineWidth(n.lineWidth||1);for(var p=0,c=e.length;p1||d<-1||d>1||(u.push(h,d),p++)}var v=new Float32Array(u),m=p,b=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,b),t.bufferData(t.ARRAY_BUFFER,v,t.STATIC_DRAW),t.vertexAttribPointer(i,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(i),t.vertexAttrib1f(r,n._size);var w=g(n.fillStyle||"red");t.uniform4f(a,w[0]/255,w[1]/255,w[2]/255,w[3]/255),t.drawArrays(t.POINTS,0,m)}}function b(t,e,n){n=n||2;var o=e&&e.length,i=o?e[0]*n:t.length,r=w(t,0,i,n,!0),a=[];if(!r)return a;var s,l,u,p,c,f,h;if(o&&(r=L(t,e,r,n)),t.length>80*n){s=u=t[0],l=p=t[1];for(var d=n;du&&(u=c),f>p&&(p=f);h=Math.max(u-s,p-l)}return x(r,a,n,s,l,h),a}function w(t,e,n,o,i){var r,a;if(i===Y(t,e,n,o)>0)for(r=e;r=e;r-=o)a=V(r,t[r],t[r+1],a);return a&&F(a,a.next)&&(H(a),a=a.next),a}function _(t,e){if(!t)return t;e||(e=t);var n,o=t;do{if(n=!1,o.steiner||!F(o,o.next)&&0!==I(o.prev,o,o.next))o=o.next;else{if(H(o),(o=e=o.prev)===o.next)return null;n=!0}}while(n||o!==e);return e}function x(t,e,n,o,i,r,a){if(t){!a&&r&&E(t,o,i,r);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,r?M(t,o,i,r):O(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),H(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?(t=S(t,e,n),x(t,e,n,o,i,r,2)):2===a&&k(t,e,n,o,i,r):x(_(t),e,n,o,i,r,1);break}}}function O(t){var e=t.prev,n=t,o=t.next;if(I(e,n,o)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(B(e.x,e.y,n.x,n.y,o.x,o.y,i.x,i.y)&&I(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function M(t,e,n,o){var i=t.prev,r=t,a=t.next;if(I(i,r,a)>=0)return!1;for(var s=i.xr.x?i.x>a.x?i.x:a.x:r.x>a.x?r.x:a.x,p=i.y>r.y?i.y>a.y?i.y:a.y:r.y>a.y?r.y:a.y,c=D(s,l,e,n,o),f=D(u,p,e,n,o),h=t.nextZ;h&&h.z<=f;){if(h!==t.prev&&h!==t.next&&B(i.x,i.y,r.x,r.y,a.x,a.y,h.x,h.y)&&I(h.prev,h,h.next)>=0)return!1;h=h.nextZ}for(h=t.prevZ;h&&h.z>=c;){if(h!==t.prev&&h!==t.next&&B(i.x,i.y,r.x,r.y,a.x,a.y,h.x,h.y)&&I(h.prev,h,h.next)>=0)return!1;h=h.prevZ}return!0}function S(t,e,n){var o=t;do{var i=o.prev,r=o.next.next;!F(i,r)&&N(i,o,o.next,r)&&W(i,r)&&W(r,i)&&(e.push(i.i/n),e.push(o.i/n),e.push(r.i/n),H(o),H(o.next),o=t=r),o=o.next}while(o!==t);return o}function k(t,e,n,o,i,r){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&R(a,s)){var l=q(a,s);return a=_(a,a.next),l=_(l,l.next),x(a,e,n,o,i,r),void x(l,e,n,o,i,r)}s=s.next}a=a.next}while(a!==t)}function L(t,e,n,o){var i,r,a,s,l,u=[];for(i=0,r=e.length;i=o.next.y){var s=o.x+(r-o.y)*(o.next.x-o.x)/(o.next.y-o.y);if(s<=i&&s>a){if(a=s,s===i){if(r===o.y)return o;if(r===o.next.y)return o.next}n=o.x=o.x&&o.x>=p&&B(rn.x)&&W(o,t)&&(n=o,f=l),o=o.next;return n}function E(t,e,n,o){var i=t;do{null===i.z&&(i.z=D(i.x,i.y,e,n,o)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,z(i)}function z(t){var e,n,o,i,r,a,s,l,u=1;do{for(n=t,t=null,r=null,a=0;n;){for(a++,o=n,s=0,e=0;e0||l>0&&o;)0===s?(i=o,o=o.nextZ,l--):0!==l&&o?n.z<=o.z?(i=n,n=n.nextZ,s--):(i=o,o=o.nextZ,l--):(i=n,n=n.nextZ,s--),r?r.nextZ=i:t=i,i.prevZ=r,r=i;n=o}r.nextZ=null,u*=2}while(a>1);return t}function D(t,e,n,o,i){return t=32767*(t-n)/i,e=32767*(e-o)/i,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 A(t){var e=t,n=t;do{e.x=0&&(t-a)*(o-s)-(n-a)*(e-s)>=0&&(n-a)*(r-s)-(i-a)*(o-s)>=0}function R(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!U(t,e)&&W(t,e)&&W(e,t)&&Z(t,e)}function I(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function F(t,e){return t.x===e.x&&t.y===e.y}function N(t,e,n,o){return!!(F(t,e)&&F(n,o)||F(t,o)&&F(n,e))||I(t,e,n)>0!=I(t,e,o)>0&&I(n,o,t)>0!=I(n,o,e)>0}function U(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&&N(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function W(t,e){return I(t.prev,t,t.next)<0?I(t,e,t.next)>=0&&I(t,t.prev,e)>=0:I(t,e,t.prev)<0||I(t,t.next,e)<0}function Z(t,e){var n=t,o=!1,i=(t.x+e.x)/2,r=(t.y+e.y)/2;do{n.y>r!=n.next.y>r&&i<(n.next.x-n.x)*(r-n.y)/(n.next.y-n.y)+n.x&&(o=!o),n=n.next}while(n!==t);return o}function q(t,e){var n=new J(t.i,t.x,t.y),o=new J(e.i,e.x,e.y),i=t.next,r=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,o.next=n,n.prev=o,r.next=o,o.prev=r,o}function V(t,e,n,o){var i=new J(t,e,n);return o?(i.next=o.next,i.prev=o,o.next.prev=i,o.next=i):(i.prev=i,i.next=i),i}function H(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 J(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 Y(t,e,n,o){for(var i=0,r=e,a=n-o;r65536&&(t.bufferData(t.ARRAY_BUFFER,new Float32Array(u),t.STATIC_DRAW),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array(p),t.STATIC_DRAW),t.drawElements(t.TRIANGLES,p.length,t.UNSIGNED_SHORT,0),u.length=0,p.length=0,c=0);for(var m=0;m0&&(n=n.concat(i))}return n}function K(t,e,n){if(!t||!e)return null;var o,i,r,a,s,l,u=function(t){return 1-2*t+t*t},p=function(t){return 2*t-2*t*t},c=function(t){return t*t},f=[],n=n||40,h=0,d=0;if(void 0===e)return void(void 0!==f&&(f=[]));var y=parseFloat(t.lat),g=parseFloat(e.lat),v=parseFloat(t.lng),m=parseFloat(e.lng);for(m>v&&parseFloat(m-v)>180&&v<0&&(v=parseFloat(360+v)),v>m&&parseFloat(v-m)>180&&m<0&&(m=parseFloat(360+m)),0,l=0,g==y?(o=0,i=v-m):m==v?(o=Math.PI/2,i=y-g):(o=Math.atan((g-y)/(m-v)),i=(g-y)/Math.sin(o)),0==l&&(l=o+Math.PI/5),r=i/2,s=r*Math.cos(l)+v,a=r*Math.sin(l)+y,h=0;hi&&o>r}function ot(t){requestAnimationFrame(ot),At.update(t)}function it(t){function e(t,e){return function(){e.apply(t)}}this.isAdded_=!1,this.isAnimated_=!1,this.paneName_=it.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 rt=function(t){t&&t.clearRect&&t.clearRect(0,0,t.canvas.width,t.canvas.height)},at=function(t){var e=window.devicePixelRatio||1;t.canvas.width=t.canvas.width*e,t.canvas.height=t.canvas.height*e,t.canvas.style.width=t.canvas.width/e+"px",t.canvas.style.height=t.canvas.height/e+"px",t.scale(e,e)};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 o=0;on&&(n=i)}return n}},i.prototype.getSum=function(t){var e=this._data;if(e&&!(e.length<=0)){for(var n=0,o=0;on&&(t=n),te&&(t=e),t1){var w=v-m,_=m+(vO*O+P*P&&(m=_+(1&g?1:-1)/2,g=x)}var M=m+"-"+g,S=c[M];S?S.push(o[f]):(S=c[M]=[o[f]],S.i=m,S.j=g,S.x=(m+(1&g?.5:0))*u,S.y=g*p)}var k=new l({max:n.max||100,maxSize:s,gradient:n.gradient});for(var r in c){var L=c[r];t.beginPath();for(var C=0;C<6;C++){var j=h({x:L.x+a.x,y:L.y+a.y},s,C);t.lineTo(j[0],j[1])}t.closePath();for(var T=0,f=0;f0&&(o+=t[i-1].length,n.holes.push(o))}return n};var kt=["attribute vec4 a_Position;","void main() {","gl_Position = a_Position;","gl_PointSize = 30.0;","}"].join(""),Lt=["precision mediump float;","uniform vec4 u_FragColor;","void main() {","gl_FragColor = u_FragColor;","}"].join(""),Ct={draw:G},jt={draw:function(t,e,n){var o=e instanceof i?e.get():e;o.length>0&&("LineString"==o[0].geometry.type?Ot.draw(t,o,n):"Polygon"==o[0].geometry.type||"MultiPolygon"==o[0].geometry.type?Ct.draw(t,o,n):St.draw(t,o,n))}},Tt={getPoints:X},Et=function(){function t(t,e){return t.x*e.x+t.y*e.y}function e(t){return{x:O[t.target].x-O[t.source].x,y:O[t.target].y-O[t.source].y}}function n(t){return Math.sqrt(Math.pow(O[t.source].x-O[t.target].x,2)+Math.pow(O[t.source].y-O[t.target].y,2))}function o(t){return Math.sqrt(Math.pow(t.source.x-t.target.x,2)+Math.pow(t.source.y-t.target.y,2))}function i(t){return{x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2}}function r(t){for(var e=0,n=1;nB||Math.abs(s.y)>B){var l=1/Math.pow(o({source:k[r[a]][e],target:k[t][e]}),1);i.x+=s.x*l,i.y+=s.y*l}}return i}function h(t,e,o){for(var i=L/(n(M[t])*(e+1)),r=[{x:0,y:0}],a=1;as;){var c=s/p,f=k[e][u-1].x,h=k[e][u-1].y;f+=c*(k[e][u].x-k[e][u-1].x),h+=c*(k[e][u].y-k[e][u-1].y),l.push({x:f,y:h}),p-=s,s=o}s-=p}l.push(O[M[e].target]),k[e]=l}}function y(o,i){return Math.abs(t(e(o),e(i))/(n(o)*n(i)))}function g(t,e){var o=(n(t)+n(e))/2;return 2/(o/Math.min(n(t),n(e))+Math.max(n(t),n(e))/o)}function v(t,e){var o=(n(t)+n(e))/2;return o/(o+a({x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2},{x:(O[e.source].x+O[e.target].x)/2,y:(O[e.source].y+O[e.target].y)/2}))}function m(t,e){var n=s(O[e.source],{source:O[t.source],target:O[t.target]}),o=s(O[e.target],{source:O[t.source],target:O[t.target]}),i={x:(n.x+o.x)/2,y:(n.y+o.y)/2},r={x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2};return Math.max(0,1-2*a(r,i)/a(n,o))}function b(t,e){return Math.min(m(t,e),m(e,t))}function w(t,e){return y(t,e)*g(t,e)*v(t,e)*b(t,e)}function _(t,e){return w(t,e)>=A}function x(){for(var t=0;t=n.length-1));r++);this.splitList.other=n[n.length-1]},Q.prototype.getLegend=function(t){var e=this.splitList,n=document.createElement("div");n.style.cssText="background:#fff; padding: 5px; border: 1px solid #ccc;";var o="";for(var i in e)o+='
'+i+"
";return n.innerHTML=o,n},$.prototype.get=function(t){for(var e=this.splitList,n=!1,o=0;o=e[o].start)&&(void 0===e[o].end||void 0!==e[o].end&&t1?1:w,_=h(w);for(u in i)if(void 0!==o[u]){var x=o[u]||0,O=i[u];O instanceof Array?n[u]=d(O,_):("string"==typeof O&&(O="+"===O.charAt(0)||"-"===O.charAt(0)?x+parseFloat(O):parseFloat(O)),"number"==typeof O&&(n[u]=x+(O-x)*_))}if(null!==m&&m.call(n,_),1===w){if(s>0){isFinite(s)&&s--;for(u in r){if("string"==typeof i[u]&&(r[u]=r[u]+parseFloat(i[u])),l){var P=r[u];r[u]=i[u],i[u]=P}o[u]=r[u]}return l&&(p=!p),f=void 0!==e?t+e:t+c,!0}null!==b&&b.call(n,n);for(var M=0,S=y.length;M1?r(t[n],t[n-1],n-o):r(t[i],t[i+1>n?n:i+1],o-i)},Bezier:function(t,e){for(var n=0,o=t.length-1,i=Math.pow,r=At.Interpolation.Utils.Bernstein,a=0;a<=o;a++)n+=i(1-e,o-a)*i(e,a)*t[a]*r(o,a);return n},CatmullRom:function(t,e){var n=t.length-1,o=n*e,i=Math.floor(o),r=At.Interpolation.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(i=Math.floor(o=n*(1+e))),r(t[(i-1+n)%n],t[i],t[(i+1)%n],t[(i+2)%n],o-i)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-o)-t[0]):e>1?t[n]-(r(t[n],t[n],t[n-1],t[n-1],o-n)-t[n]):r(t[i?i-1:0],t[i],t[n1;o--)n*=o;return t[e]=n,n}}(),CatmullRom:function(t,e,n,o,i){var r=.5*(n-t),a=.5*(o-e),s=i*i;return(2*e-2*n+r+a)*(i*s)+(-3*e+3*n-2*r-a)*s+r*i+e}}};var Bt={draw:function(t,e,n){var o=e instanceof i?e.get():e;t.save();for(var r in n)t[r]=n[r];var a=n.offset||{x:0,y:0},s=[],l=n._size||n.size;l?t.font="bold "+l+"px Arial":l=12;var u=n.textKey||"text";if(n.textAlign||(t.textAlign="center"),n.textBaseline||(t.textBaseline="middle"),n.avoid)for(var p=0,c=o.length;pi&&(e[o]._size=r),t.lineWidth=1,t.strokeStyle=e[o].strokeStyle||e[o]._strokeStyle||n.strokeStyle||"yellow",t.stroke();var a=e[o].fillStyle||e[o]._fillStyle||n.fillStyle;a&&(t.fillStyle=a,t.fill())}else if("LineString"===e[o].geometry.type){t.beginPath();var s=e[o].size||this.options.size||5,r=e[o].minSize||this.options.minSize||0;void 0===e[o]._index&&(e[o]._index=0);var l=e[o]._index;t.arc(e[o].geometry._coordinates[l][0],e[o].geometry._coordinates[l][1],s,0,2*Math.PI,!0),t.closePath(),e[o]._index++,e[o]._index>=e[o].geometry._coordinates.length&&(e[o]._index=0);var u=e[o].strokeStyle||n.strokeStyle,a=e[o].fillStyle||n.fillStyle||"yellow";t.fillStyle=a,t.fill(),u&&n.lineWidth&&(t.lineWidth=n.lineWidth||1,t.strokeStyle=u,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()}}]),e}(It),Nt=function(t){function e(t,n,o){ut(this,e);var i=ht(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,o)),r=i;o=o||{},i.clickEvent=i.clickEvent.bind(i),i.mousemoveEvent=i.mousemoveEvent.bind(i),r.init(o),r.argCheck(o),r.transferToMercator();var a=i.canvasLayer=new tt({map:t,context:i.context,paneName:o.paneName,mixBlendMode:o.mixBlendMode,enableMassClear:o.enableMassClear,zIndex:o.zIndex,update:function(){r._canvasUpdate()}});return n.on("change",function(){r.transferToMercator(),a.draw()}),i}return ft(e,t),pt(e,[{key:"clickEvent",value:function(t){var n=t.pixel;ct(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"clickEvent",this).call(this,n,t)}},{key:"mousemoveEvent",value:function(t){var n=t.pixel;ct(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"mousemoveEvent",this).call(this,n,t)}},{key:"bindEvent",value:function(t){this.unbindEvent();var e=this.map;this.options.methods&&(this.options.methods.click&&(e.setDefaultCursor("default"),e.addEventListener("click",this.clickEvent)),this.options.methods.mousemove&&e.addEventListener("mousemove",this.mousemoveEvent))}},{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(){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:"getContext",value:function(){return this.canvasLayer.canvas.getContext(this.context)}},{key:"_canvasUpdate",value:function(t){if(this.canvasLayer){var e=this,n=e.options.animation,o=this.canvasLayer._map,i=Math.pow(2,18-o.getZoom()),r=o.getMapType().getProjection(),a=r.lngLatToPoint(o.getCenter()),s=new BMap.Pixel(a.x-o.getSize().width/2*i,a.y+o.getSize().height/2*i),l=this.getContext();if(e.isEnabledTime()){if(void 0===t)return void rt(l);"2d"==this.context&&(l.save(),l.globalCompositeOperation="destination-out",l.fillStyle="rgba(0, 0, 0, .1)",l.fillRect(0,0,l.canvas.width,l.canvas.height),l.restore())}else rt(l);if("2d"==this.context)for(var u in e.options)l[u]=e.options[u];else l.clear(l.COLOR_BUFFER_BIT);if(!(e.options.minZoom&&o.getZoom()e.options.maxZoom)){var p=1;"2d"!=this.context&&(p=this.canvasLayer.devicePixelRatio);var c={fromColumn:"bd09mc"==e.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-s.x)/i*p,(s.y-t[1])/i*p]}};void 0!==t&&(c.filter=function(e){var o=n.trails||10;return!!(t&&e.time>t-o&&e.timee.options.maxZoom)){var a=1;"2d"!=this.context&&(a=this.canvasLayer.devicePixelRatio);var s=this.map,l=s.getProjection(),a=Math.pow(2,s.zoom)*resolutionScale,u=l.fromLatLngToPoint(this.canvasLayer.getTopLeft()),p={transferCoordinate:function(t){var e=new google.maps.LatLng(t[1],t[0]),n=l.fromLatLngToPoint(e),o={x:(n.x-u.x)*a,y:(n.y-u.y)*a};return[o.x,o.y]}};void 0!==t&&(p.filter=function(e){var o=n.trails||10;return!!(t&&e.time>t-o&&e.time0&&!0===this.props.autoViewport&&t.setViewport(e,this.props.viewportOptions)}}},{key:"getOverlay",value:function(){return null}},{key:"options",get:function(){return["strokeColor","fillColor","strokeWeight","strokeOpacity","fillOpacity","strokeStyle","enableMassClear","enableEditing","enableClicking"]}},{key:"events",get:function(){return["click","dblclick","mousedown","mouseup","mouseout","mouseover","remove","lineupdate"]}}]),e}(l.default);e.default=u},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});for(var s=(function(){function t(t,e){for(var n=0;n-1&&(g=!1,r=r.replace(/-/,"")),r.indexOf("+")>-1&&(g=!0,r=r.replace("+","")),0==r.length&&(r="_"));var v={display:"flex",justifyContent:"space-between",background:"#FFFFFF",alignItems:"stretch",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.22)",borderRadius:"3px 0 0 3px",minWidth:"155px",minHeight:"50px",marginTop:"-25px"},m={minWidth:"30px",background:"#999999",color:"white",padding:"auto 0",display:"flex",justifyContent:"center",alignItems:"center"};this.props.active&&(m.background="#F5533D"),this.props.leftStyle&&(m=d.obj.merge(m,this.props.leftStyle)),this.props.style&&(v=d.obj.merge(v,this.props.style));var b={flex:"1",padding:"6px",justifyContent:"center",alignItems:"center",fontSize:"12px",color:"#8D93A3",letterSpacing:"0.6px"};this.props.rightStyle&&(b=d.obj.merge(b,this.props.rightStyle));var w=Object.keys(t.props).filter(function(t){return 0==t.indexOf("on")}),_=[];if(w.map(function(e){_.push(i({},e,t.props[e]))}),f)return c.default.createElement(h.default,{key:JSON.stringify(y)+Math.random(),map:this.props.map,position:y},c.default.createElement("div",l({key:JSON.stringify(y)+Math.random(),style:v},_),c.default.createElement("div",{style:m},u),c.default.createElement("div",{style:b},!s&&c.default.createElement("div",null," ",o+"("+r,g?c.default.createElement("img",{style:{width:"8px",height:"auto",margin:"1px"},src:"//huiyan.baidu.com/cms/react-bmap/up.png"}):c.default.createElement("img",{style:{width:"8px",height:"auto",margin:"1px"},src:"//huiyan.baidu.com/cms/react-bmap/down.png"}),")"),s||c.default.createElement("div",null," ",a," "))))}},{key:"render",value:function(){return this.createMarker()}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(c.default.Component);e.default=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=void 0,o=void 0;try{if("string"==typeof t){var i=t.split(",");n=JSON.parse(i[0].match(/[0-9]+\.?[0-9]{0,}/)[0]),o=JSON.parse(i[1].match(/[0-9]+\.?[0-9]{0,}/)[0])}else t instanceof Array?(n=JSON.parse(t[0]),o=JSON.parse(t[1])):t instanceof Object&&(n=t.lng,o=t.lat);if(e)return{lng:n,lat:o};return new BMap.Point(n,o)}catch(t){console.log("create BmapPoint error",'Please input data like this: 1. "114.54,40.33", 2.[114.54,40.33], 3.{lng:114.54,lat:40.33}')}};e.default=o},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var i=n(10);Object.defineProperty(e,"Map",{enumerable:!0,get:function(){return o(i).default}});var r=n(5);Object.defineProperty(e,"Marker",{enumerable:!0,get:function(){return o(r).default}});var a=n(7);Object.defineProperty(e,"MarkerOrderTip",{enumerable:!0,get:function(){return o(a).default}});var s=n(21);Object.defineProperty(e,"InfoWindow",{enumerable:!0,get:function(){return o(s).default}});var l=n(22);Object.defineProperty(e,"NavigationControl",{enumerable:!0,get:function(){return o(l).default}});var u=n(23);Object.defineProperty(e,"OverviewMapControl",{enumerable:!0,get:function(){return o(u).default}});var p=n(24);Object.defineProperty(e,"ScaleControl",{enumerable:!0,get:function(){return o(p).default}});var c=n(25);Object.defineProperty(e,"MapTypeControl",{enumerable:!0,get:function(){return o(c).default}});var f=n(26);Object.defineProperty(e,"PanoramaControl",{enumerable:!0,get:function(){return o(f).default}});var h=n(27);Object.defineProperty(e,"Circle",{enumerable:!0,get:function(){return o(h).default}});var d=n(28);Object.defineProperty(e,"Polyline",{enumerable:!0,get:function(){return o(d).default}});var y=n(29);Object.defineProperty(e,"Polygon",{enumerable:!0,get:function(){return o(y).default}});var g=n(30);Object.defineProperty(e,"Road",{enumerable:!0,get:function(){return o(g).default}});var v=n(34);Object.defineProperty(e,"Boundary",{enumerable:!0,get:function(){return o(v).default}});var m=n(35);Object.defineProperty(e,"MarkerList",{enumerable:!0,get:function(){return o(m).default}});var b=n(37);Object.defineProperty(e,"MapvMarkerList",{enumerable:!0,get:function(){return o(b).default}});var w=n(38);Object.defineProperty(e,"TrafficLayer",{enumerable:!0,get:function(){return o(w).default}});var _=n(39);Object.defineProperty(e,"Merge",{enumerable:!0,get:function(){return o(_).default}});var x=n(40);Object.defineProperty(e,"MapvLayer",{enumerable:!0,get:function(){return o(x).default}});var O=n(41);Object.defineProperty(e,"DrivingRoute",{enumerable:!0,get:function(){return o(O).default}});var P=n(42);Object.defineProperty(e,"PointLabel",{enumerable:!0,get:function(){return o(P).default}});var M=n(45);Object.defineProperty(e,"Arc",{enumerable:!0,get:function(){return o(M).default}});var S=n(46);Object.defineProperty(e,"ThickRay",{enumerable:!0,get:function(){return o(S).default}});var k=n(47);Object.defineProperty(e,"MapListener",{enumerable:!0,get:function(){return o(k).default}})},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1])||arguments[1],n=[];return t.split("|").forEach(function(t){for(var o=t?t.split(","):[],r=[],a=0;a=200&&this.status<300?t.success&&t.success(JSON.parse(this.response)):t.fail&&t.fail(this.statusText),t.complete&&t.complete(JSON.parse(this.response)),clearTimeout(a)},n.onerror=function(){t.fail&&t.fail(e.statusText),clearTimeout(a)},{abort:function(){i||(i=!0,n.abort())},params:t}}function r(t){var e="jsonp_"+ +new Date+"_"+parseInt(1e7*Math.random(),10),n=document.createElement("script"),o=!1;t.url+="-1"===t.url.indexOf("?")?"?":"&",t.url+="callback="+e,n.src=t.url,document.head.appendChild(n);var i=setTimeout(function(){null!==window[e]&&(window[e]=null,n.parentElement.removeChild(n),t.fail&&t.fail({error:null,msg:"timeout"}),t.complete&&t.complete(JSON.parse()))},1e4);return n.addEventListener("error",function(r){window[e]=null,n.parentElement.removeChild(n),clearTimeout(i),o||(t.fail&&t.fail({error:r,msg:"loaderror"}),t.complete&&t.complete())}),window[e]=function(r){clearTimeout(i),o||(t.success(r),t.complete&&t.complete()),window[e]=null,n.parentElement.removeChild(n)},{abort:function(){clearTimeout(i),o=!0},params:t}}Object.defineProperty(e,"__esModule",{value:!0});var a={fetch:o,ajax:i,jsonp:r,test:function(){console.log("test kits-js http")}};e.default=a},function(t,e,n){"use strict";function o(t,e,n){this._point=t,this.content=e,this.offset=n||new BMap.Size(0,0)}Object.defineProperty(e,"__esModule",{value:!0}),o.prototype=new BMap.Overlay,o.prototype.initialize=function(t){this._map=t;var e=this._div=document.createElement("div");return e.setAttribute("tag","customoverlay"),e.style.position="absolute",e.style.zIndex=BMap.Overlay.getZIndex(this._point.lat),e.addEventListener("touchstart",function(t){t.stopPropagation(),console.log("touchstart")}),e.addEventListener("touchend",function(t){t.stopPropagation(),console.log("touchend")}),"[object String]"==Object.prototype.toString.call(this.content)?e.innerHTML=this.content:e.appendChild(this.content),t.getPanes().labelPane.appendChild(e),e},o.prototype.draw=function(){var t=this._map,e=t.pointToOverlayPixel(this._point);this._div.style.left=e.x+this.offset.width+"px",this._div.style.top=e.y+this.offset.height+"px"},e.default=o},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==this.props.autoViewport&&this.props.map.setViewport(e,this.props.viewportOptions)}},{key:"getRoadGroup",value:function(t,e,n){var t=t,e=e,n=n,o={},i=[];if(e)for(var r=0;r1)for(var n=1;n3&&void 0!==arguments[3]?arguments[3]:{},r=t.getZoom(),a=i.lineWidth||5,s=void 0===i.level?1:i.level,l=null,u=0,p=0,c=[],f=[],h=[],d=0,y=0;e.beginPath();var g,v=Math.pow(2,18-t.getZoom()),m=t.getMapType().getProjection(),b=m.lngLatToPoint(t.getCenter()),w=new BMap.Pixel(b.x-t.getSize().width/2*v,b.y+t.getSize().height/2*v);return n.forEach(function(n,o){var r=null;l=null;for(var a=n.split(","),s=0;s=50&&(h.push(b),d%=50))}l=g,0===s?(r=r||g,e.moveTo(g.x,g.y)):(p>15||s>=a.length-2)&&(p=0,e.lineTo(g.x,g.y))}if(i.arrow&&o===n.length-1&&y<100){var O=c[Math.ceil(c.length/2)];for(var P in c)if(c[P].totalDepth>=y/2){O=c[P+1]?c[P+1]:c[P];break}var M=c[c.length-1];O.end=M.end,h=[],h.push(O)}}),i.line&&(e.lineCap=i.lineCap||"round",e.lineJoin="round",i.border&&(e.strokeStyle=i.border.color||"white",e.lineWidth=(r<=13?a-2:a)+(2*i.border.lineWidth||4),e.stroke()),e.strokeStyle=i.color||o[s]||"#fc2c2b",e.lineWidth=r<=13?a-2:a,e.stroke()),i.arrow&&this.drawArrow(e,h,i),f},drawArrow:function(t,e,n){t.beginPath(),e.forEach(function(o){var i=o.start.x,r=o.start.y,a=o.end.x,s=o.end.y,l=a-i,u=s-r,p=[0,-1],c=[o.end.x-o.start.x,o.end.y-o.start.y],f=p[0]*c[0]+p[1]*c[1],h=Math.sqrt(p[0]*p[0]+p[1]*p[1]),d=Math.sqrt(c[0]*c[0]+c[1]*c[1]),y=Math.acos(f/(h*d));c[0]<0&&(y=2*Math.PI-y);for(var g=n.arrow.width/2||2,v=n.arrow.height||g,m=0;o.offset+50*m<=o.depth;){var b=o.offset+50*m,w=b/o.depth;t.save(),t.translate(i+l*w,r+u*w),t.rotate(y),t.moveTo(1.618*-g,v),t.lineTo(0,0),t.lineTo(1.618*g,v),t.restore(),m+=1}1===e.length&&o.offset>o.depth&&(t.save(),t.translate(i,r),t.rotate(y),t.moveTo(1.618*-g,v),t.lineTo(0,0),t.lineTo(1.618*g,v),t.restore())}),t.strokeStyle=n.arrow.color||"#fff",t.lineWidth=3,t.stroke()}};e.default=i},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var o={mergeRoadPath:function(t,e){for(var n=[],o=0;o=Math.min(i.lng,r.lng)&&t.lng<=Math.max(i.lng,r.lng)&&t.lat>=Math.min(i.lat,r.lat)&&t.lat<=Math.max(i.lat,r.lat)){var a=(i.lng-t.lng)*(r.lat-t.lat)-(r.lng-t.lng)*(i.lat-t.lat),s=2e-10;if(s=2e-9,a-s)return!0}}return!1}};e.default=o},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==o.props.autoViewport&&n.setViewport(i,o.props.viewportOptions)}}var e=this.props.data,n=this.props.map;if(e){this._request={};var o=this,i=new BMap.Boundary,r=[];e.forEach(function(t,e){o._request[t.name]=!1,o._backData[t.name]&&(r=r.concat(o._backData[t.name]),o._request[t.name]=!0)}),t(),e.forEach(function(e,n){o._request[e.name]||o._allRequest[e.name]||(o._allRequest[e.name]=!0,i.get(e.name,function(n){for(var i=[],a=0;a=10&&(n.isShowNumber=!1,n.size=10,n.strokeStyle=h,n.lineWidth=3,n.strokeOpacity=.4));var d=new f.default(n);d.addEventListener("click",function(e,n){t.props.onClick&&t.props.onClick(n-1)}),d.addEventListener("mouseover",function(e,n){t.props.onMouseOver&&t.props.onMouseOver(n-1)}),d.addEventListener("mouseout",function(e,n){t.props.onMouseOut&&t.props.onMouseOut(n-1)}),d.index=l,this.markers.push(d),s.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:a[l].count,text:a[l].text})}for(var y=this.markers.length;y--;)e.addOverlay(this.markers[y]);this.dataSet.set(s.splice(0,10)),this.setViewport()}}},{key:"setViewport",value:function(){var t=this.props.map;if(t){for(var e=this.props.data,n=t.getMapType().getProjection(),o=[],i=0;i0&&!1!==this.props.autoViewport&&t.setViewport(o,this.props.viewportOptions)}}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(u.default);e.default=h},function(t,e,n){"use strict";function o(t){this.options=t||{},this._point=t.point,this._fillColor=t.fillStyle||"#1495ff",this._size=t.size||30,this._lineWidth=void 0===t.lineWidth?2:t.lineWidth,this._strokeStyle=t.strokeStyle||"#ffffff",t.strokeOpacity&&(this._strokeStyle=i(this._strokeStyle,.4))}function i(t,e){var n=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,o=t.toLowerCase();if(o&&n.test(o)){if(4===o.length){for(var i="#",r=1;r<4;r+=1)i+=o.slice(r,r+1).concat(o.slice(r,r+1));o=i}for(var a=[],r=1;r<7;r+=2)a.push(parseInt("0x"+o.slice(r,r+2)));return e?(a.push(e),"rgba("+a.join(",")+")"):"rgb("+a.join(",")+")"}return o}Object.defineProperty(e,"__esModule",{value:!0}),o.prototype=new BMap.Overlay,o.prototype.initialize=function(t){this._map=t;var e=this._div=document.createElement("div"),n=e.style;n.position="absolute",n.backgroundClip="padding-box",n.zIndex=this.options.zIndex||BMap.Overlay.getZIndex(this._point.lat),n.backgroundColor=this._fillColor,!1!==this.options.isShowShadow&&(n.boxShadow="0 0 5px rgba(0, 0, 0, 0.5)"),n.border=this._lineWidth+"px solid "+this._strokeStyle,n.color="white",n.textShadow="0px 0px 5px #fff",n.width=this._size+"px",n.boxSizing="content-box",n.borderRadius="30px",n.height=this._size+"px",n.lineHeight=this._size+"px",n.fontSize="12px",n.cursor="pointer",n.textAlign="center",n.MozUserSelect="none",this.options.number&&!1!==this.options.isShowNumber&&(e.innerHTML=this.options.number);var o=this;return e.addEventListener("mouseover",function(){o.dispatchEvent("mouseover",o.options.number),n.backgroundColor="#1495ff"}),e.addEventListener("mouseout",function(){o.dispatchEvent("mouseout",o.options.number),n.backgroundColor=o._fillColor}),e.addEventListener("click",function(){o.dispatchEvent("click",o.options.number)}),t.getPanes().markerPane.appendChild(e),e},o.prototype.draw=function(){var t=this._map,e=t.pointToOverlayPixel(this._point);this._div.style.left=e.x-(this._size+this._lineWidth)/2+1+"px",this._div.style.top=e.y-(this._size+this._lineWidth)/2+"px"},e.default=o},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&(t.forEach(function(t,l){var u=t.location.split(","),p=e.project.pointToLngLat(new BMap.Pixel(u[0],u[1]));s.push(p),l<10?(n.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count)}),o.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},id:l,count:parseInt(t.count),text:parseInt(l)+1}),i.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count),text:t.text})):(r.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},id:l,count:parseInt(t.count)}),a.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count)}))}),this.shadowSet.set(n),this.circleSet.set(o),this.textSet.set(i),this.numSet.set(o),this.otherSet.set(r),this.otherShadowSet.set(a),s.length>0&&!1!==this.props.autoViewport&&map.setViewport(s,self.props.viewportOptions))}},{key:"createLayers",value:function(){this._createLayer=!0;var t=this.map;this.project=t.getMapType().getProjection();var e=this,n=this.shadowSet=new u.DataSet([]),o=this.circleSet=new u.DataSet([]),i=this.textSet=new u.DataSet([]),r=this.numSet=new u.DataSet([]),a=this.otherSet=new u.DataSet([]),s=this.otherShadowSet=new u.DataSet([]);this.layers=[];var l={coordType:"bd09mc",splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",other:"#80db69"},shadowBlur:10,size:5,max:30,methods:{click:function(t){t&&e.handleClick(t.id)},mousemove:function(t){a.update(function(t){t.fillStyle=null}),t?(e.isSmallPath=!0,e.props.map.setDefaultCursor("pointer"),a.update(function(t){t.fillStyle="#1495ff"},{id:t.id})):(e.isSmallPath=!1,e.isSmallPath||e.isBigPath||e.props.map.setDefaultCursor("auto"))}},draw:"category"},p={splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",1:"#80db69"},styleType:"fill",globalAlpha:.4,coordType:"bd09mc",size:8,minSize:5,draw:"category"};if(this.layers.push(new u.baiduMapLayer(t,s,p)),this.layers.push(new u.baiduMapLayer(t,a,l)),!0===this.props.animation){var c={splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",1:"#80db69"},styleType:"stroke",globalAlpha:.4,coordType:"bd09mc",size:20,minSize:10,draw:"category"};this.layers.push(new u.baiduMapAnimationLayer(t,n,c))}var f={splitList:{1:"#80db69",4:"#d53938",3:"#fe6261",2:"#ffb02d"},fillStyle:"red",coordType:"bd09mc",size:10,draw:"category",methods:{click:function(t){t&&e.handleClick(t.id)},mousemove:function(t){o.update(function(t){t.fillStyle=null}),t?(e.isBigPath=!0,e.map.setDefaultCursor("pointer"),o.update(function(t){t.fillStyle="#1495ff"},{id:t.id})):(e.isBigPath=!1,e.isBigPath||e.isSmallPath||e.map.setDefaultCursor("auto"))}}};this.layers.push(new u.baiduMapLayer(t,o,f));var h={coordType:"bd09mc",draw:"text",font:"13px Arial",fillStyle:"#ffffff",shadowColor:"#ffffff",shadowBlur:10};this.layers.push(new u.baiduMapLayer(t,r,h));var d={coordType:"bd09mc",font:"13px Arial",fillStyle:"#666",shadowColor:"#ffffff",shadowBlur:10,draw:"text",avoid:!0,textAlign:"left",offset:{x:10,y:0}};this.layers.push(new u.baiduMapLayer(t,i,d))}},{key:"render",value:function(){return null}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(l.default);e.default=p},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;nthis.minX&&t.lat>this.minY&&t.lngthis.minX&&t.minY>this.minY&&t.maxX=Math.min(i.lng,r.lng)&&t.lng<=Math.max(i.lng,r.lng)&&t.lat>=Math.min(i.lat,r.lat)&&t.lat<=Math.max(i.lat,r.lat)){var a=(i.lng-t.lng)*(r.lat-t.lat)-(r.lng-t.lng)*(i.lat-t.lat),s=2e-10;if(s=2e-9,a-s)return!0}}return!1},e.default=i},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==t.props.autoViewport&&e.setViewport(i,t.props.viewportOptions)})}this.lineDataSet.set(n),this.lineLayer.update({options:this.props.lineOptions||{draw:"simple",strokeStyle:"#5E87DB",lineWidth:3}}),this.pointDataSet.set(o),this.pointLayer.update({options:this.props.pointOptions||{coordType:this.props.coordType,draw:"simple",fillStyle:"#5E87DB",size:5}}),this.textLayer.update({options:this.props.textOptions||{coordType:this.props.coordType,draw:"text",font:"18px Arial",offset:{x:0,y:12},fillStyle:"#333",size:12}}),this.props.enableAnimation?this.animationLayer.update({options:this.props.animationOptions||{coordType:this.props.coordType,fillStyle:"rgba(255, 250, 250, 0.9)",lineWidth:0,size:4,animateTime:50,draw:"simple"}}):this.animationLayer&&this.animationLayer.hide()}}}],[{key:"defaultProps",get:function(){return{}}}]),e}(p.default);e.default=f},function(t,e,n){"use strict";function o(t){return t&&t.__esModule?t:{default:t}}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n0&&!1!==t.props.autoViewport&&e.setViewport(i,t.props.viewportOptions)})}this.lineDataSet.set(n),this.lineLayer.update({options:this.props.lineOptions||{coordType:this.props.coordType,draw:"simple",strokeStyle:"#5E87DB",globalCompositeOperation:"lighter",shadowColor:"rgba(255, 255, 255, 0.5)",shadowBlur:60,lineWidth:2}}),this.pointDataSet.set(o),this.pointLayer.update({options:this.props.pointOptions||{coordType:this.props.coordType,draw:"simple",fillStyle:"#5E87DB",size:5,shadowColor:"#5E87DB",shadowBlur:20}}),this.textLayer.update({options:this.props.textOptions||{coordType:this.props.coordType,draw:"text",font:"18px Arial",offset:{x:0,y:12},fillStyle:"#333",size:12}})}}}],[{key:"defaultProps",get:function(){return{}}}]),e}(p.default);e.default=f},function(t,e,n){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}function a(t,e){var n=null;return function(){var o=this,i=arguments;n&&clearTimeout(n),n=setTimeout(function(){t.apply(o,i)},e)}}function s(t,e){var n=void 0,o=arguments,i=void 0;return function r(){var a=this,s=Date.now();i||(i=s),n&&clearTimeout(n),s-i>=e?(t.apply(a,o),i=s):n=setTimeout(function(){r.apply(a,o)},50)}}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var n=0;np&&(t[f]=256*p),u&&u>=s&&u<=l?(t[f-3]=e[u],t[f-2]=e[u+1],t[f-1]=e[u+2]):t[f]=0}function c(t){return t.max||100}function h(t){return t.min||0}function f(t,e,n){var i=c(n),o=h(n),r=n._size;void 0==r&&void 0==(r=n.size)&&(r=13);var a=new l({gradient:n.gradient,max:i,min:o}),s=u(r),p=s.width/2,f=s.height/2,d=e,y={};d.forEach(function(t,e){var n=void 0===t.count?1:t.count,o=Math.min(1,n/i).toFixed(2);y[o]=y[o]||[],y[o].push(t)});for(var v in y)if(!isNaN(v)){var g=y[v];t.beginPath(),n.withoutAlpha||(t.globalAlpha=v),t.strokeStyle=a.getColor(v*i),g.forEach(function(e,o){if(e.geometry){var r=e.geometry._coordinates||e.geometry.coordinates,a=e.geometry.type;if("Point"===a){var l=void 0===e.count?1:e.count;t.globalAlpha=l/i,t.drawImage(s,r[0]-p,r[1]-f)}else if("LineString"===a){var l=void 0===e.count?1:e.count;t.globalAlpha=l/i,t.beginPath(),mt.draw(t,e,n),t.stroke()}}})}}function d(t,e,n){if(!(t.canvas.width<=0||t.canvas.height<=0)){var i=n.strength||.3;t.strokeStyle="rgba(0,0,0,"+i+")";var r=new s(t.canvas.width,t.canvas.height),a=r.getContext("2d");a.scale(_t,_t),n=n||{};var u=e instanceof o?e.get():e;t.save();var c=new l({gradient:n.gradient});if(f(a,u,n),!n.absolute){var h=a.getImageData(0,0,t.canvas.width,t.canvas.height);p(h.data,c.getImageData(),n),t.putImageData(h,0,0),t.restore()}c=null,r=null}}function y(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 g(t,e,n){var i=v(t,e,t.VERTEX_SHADER),o=v(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 m(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 b(t,e,n){if(e){var i=g(t,Pt,Mt);t.enable(t.BLEND),t.blendFunc(t.SRC_ALPHA,t.ONE),t.clear(t.COLOR_BUFFER_BIT);var o=t.canvas.width/2,r=t.canvas.height/2,a=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,a);var s=t.getAttribLocation(i,"a_Position");t.vertexAttribPointer(s,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(s);var l=t.getUniformLocation(i,"u_FragColor"),u=m(n.strokeStyle||"red");t.uniform4f(l,u[0]/255,u[1]/255,u[2]/255,u[3]/255),t.lineWidth(n.lineWidth||1);for(var p=0,c=e.length;p1||d<-1||d>1||(u.push(f,d),p++)}var y=new Float32Array(u),v=p,b=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,b),t.bufferData(t.ARRAY_BUFFER,y,t.STATIC_DRAW),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o),t.vertexAttrib1f(r,n._size);var w=m(n.fillStyle||"red");t.uniform4f(a,w[0]/255,w[1]/255,w[2]/255,w[3]/255),t.drawArrays(t.POINTS,0,v)}}function _(t,e,n){n=n||2;var i=e&&e.length,o=i?e[0]*n:t.length,r=x(t,0,o,n,!0),a=[];if(!r)return a;var s,l,u,p,c,h,f;if(i&&(r=E(t,e,r,n)),t.length>80*n){s=u=t[0],l=p=t[1];for(var d=n;du&&(u=c),h>p&&(p=h);f=Math.max(u-s,p-l)}return k(r,a,n,s,l,f),a}function x(t,e,n,i,o){var r,a;if(o===G(t,e,n,i)>0)for(r=e;r=e;r-=i)a=J(r,t[r],t[r+1],a);return a&&U(a,a.next)&&(Y(a),a=a.next),a}function O(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!U(i,i.next)&&0!==N(i.prev,i,i.next))i=i.next;else{if(Y(i),(i=e=i.prev)===i.next)return null;n=!0}}while(n||i!==e);return e}function k(t,e,n,i,o,r,a){if(t){!a&&r&&R(t,i,o,r);for(var s,l,u=t;t.prev!==t.next;)if(s=t.prev,l=t.next,r?S(t,i,o,r):M(t))e.push(s.i/n),e.push(t.i/n),e.push(l.i/n),Y(t),t=l.next,u=l.next;else if((t=l)===u){a?1===a?(t=L(t,e,n),k(t,e,n,i,o,r,2)):2===a&&C(t,e,n,i,o,r):k(O(t),e,n,i,o,r,1);break}}}function M(t){var e=t.prev,n=t,i=t.next;if(N(e,n,i)>=0)return!1;for(var o=t.next.next;o!==t.prev;){if(I(e.x,e.y,n.x,n.y,i.x,i.y,o.x,o.y)&&N(o.prev,o,o.next)>=0)return!1;o=o.next}return!0}function S(t,e,n,i){var o=t.prev,r=t,a=t.next;if(N(o,r,a)>=0)return!1;for(var s=o.xr.x?o.x>a.x?o.x:a.x:r.x>a.x?r.x:a.x,p=o.y>r.y?o.y>a.y?o.y:a.y:r.y>a.y?r.y:a.y,c=B(s,l,e,n,i),h=B(u,p,e,n,i),f=t.nextZ;f&&f.z<=h;){if(f!==t.prev&&f!==t.next&&I(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&N(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=t.prevZ;f&&f.z>=c;){if(f!==t.prev&&f!==t.next&&I(o.x,o.y,r.x,r.y,a.x,a.y,f.x,f.y)&&N(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}function L(t,e,n){var i=t;do{var o=i.prev,r=i.next.next;!U(o,r)&&W(o,i,i.next,r)&&q(o,r)&&q(r,o)&&(e.push(o.i/n),e.push(i.i/n),e.push(r.i/n),Y(i),Y(i.next),i=t=r),i=i.next}while(i!==t);return i}function C(t,e,n,i,o,r){var a=t;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&F(a,s)){var l=H(a,s);return a=O(a,a.next),l=O(l,l.next),k(a,e,n,i,o,r),void k(l,e,n,i,o,r)}s=s.next}a=a.next}while(a!==t)}function E(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&&s>a){if(a=s,s===o){if(r===i.y)return i;if(r===i.next.y)return i.next}n=i.x=i.x&&i.x>=p&&I(rn.x)&&q(i,t)&&(n=i,h=l),i=i.next;return n}function R(t,e,n,i){var o=t;do{null===o.z&&(o.z=B(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,D(o)}function D(t){var e,n,i,o,r,a,s,l,u=1;do{for(n=t,t=null,r=null,a=0;n;){for(a++,i=n,s=0,e=0;e0||l>0&&i;)0===s?(o=i,i=i.nextZ,l--):0!==l&&i?n.z<=i.z?(o=n,n=n.nextZ,s--):(o=i,i=i.nextZ,l--):(o=n,n=n.nextZ,s--),r?r.nextZ=o:t=o,o.prevZ=r,r=o;n=i}r.nextZ=null,u*=2}while(a>1);return t}function B(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 A(t){var e=t,n=t;do{e.x=0&&(t-a)*(i-s)-(n-a)*(e-s)>=0&&(n-a)*(r-s)-(o-a)*(i-s)>=0}function F(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Z(t,e)&&q(t,e)&&q(e,t)&&V(t,e)}function N(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function U(t,e){return t.x===e.x&&t.y===e.y}function W(t,e,n,i){return!!(U(t,e)&&U(n,i)||U(t,i)&&U(n,e))||N(t,e,n)>0!=N(t,e,i)>0&&N(n,i,t)>0!=N(n,i,e)>0}function Z(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&&W(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}function q(t,e){return N(t.prev,t,t.next)<0?N(t,e,t.next)>=0&&N(t,t.prev,e)>=0:N(t,e,t.prev)<0||N(t,t.next,e)<0}function V(t,e){var n=t,i=!1,o=(t.x+e.x)/2,r=(t.y+e.y)/2;do{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}while(n!==t);return i}function H(t,e){var n=new $(t.i,t.x,t.y),i=new $(e.i,e.x,e.y),o=t.next,r=e.prev;return t.next=e,e.prev=t,n.next=o,o.prev=n,i.next=n,n.prev=i,r.next=i,i.prev=r,i}function J(t,e,n,i){var o=new $(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 Y(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 $(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 G(t,e,n,i){for(var o=0,r=e,a=n-i;r65536&&(t.bufferData(t.ARRAY_BUFFER,new Float32Array(u),t.STATIC_DRAW),t.bufferData(t.ELEMENT_ARRAY_BUFFER,new Uint16Array(p),t.STATIC_DRAW),t.drawElements(t.TRIANGLES,p.length,t.UNSIGNED_SHORT,0),u.length=0,p.length=0,c=0);for(var v=0;v0&&(n=n.concat(o))}return n}function Q(t,e,n){if(console.info(t,e),!t||!e)return null;var i,o,r,a,s,l,u=function(t){return 1-2*t+t*t},p=function(t){return 2*t-2*t*t},c=function(t){return t*t},h=[],n=n||40,f=0,d=0;if(void 0===e)return void(void 0!==h&&(h=[]));var y=parseFloat(t.lat),v=parseFloat(e.lat),g=parseFloat(t.lng),m=parseFloat(e.lng);for(m>g&&parseFloat(m-g)>180&&g<0&&(g=parseFloat(360+g),m=parseFloat(360+m)),0,l=0,v==y?(i=0,o=g-m):m==g?(i=Math.PI/2,o=y-v):(i=Math.atan((v-y)/(m-g)),o=(v-y)/Math.sin(i)),0==l&&(l=i+Math.PI/5),r=o/2,s=r*Math.cos(l)+g,a=r*Math.sin(l)+y,f=0;f0?b-360:b,w]),d+=1/n}return h}function tt(t){this.splitList=t||{other:1}}function et(t){this.splitList=t||[{start:0,value:"red"}]}function nt(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 it(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>r}function st(t){requestAnimationFrame(st),Ft.update(t)}function lt(t){function e(t,e){return function(){e.apply(t)}}this.isAdded_=!1,this.isAnimated_=!1,this.paneName_=lt.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 ut=function(t){t&&t.clearRect&&t.clearRect(0,0,t.canvas.width,t.canvas.height)},pt=function(t){var e=window.devicePixelRatio||1;t.canvas.width=t.canvas.width*e,t.canvas.height=t.canvas.height*e,t.canvas.style.width=t.canvas.width/e+"px",t.canvas.style.height=t.canvas.height/e+"px",t.scale(e,e)};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;in&&(n=o)}return n}},o.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),t1){var w=g-m,_=m+(gO*O+k*k&&(m=_+(1&v?1:-1)/2,v=x)}var P=m+"-"+v,M=c[P];M?M.push(i[h]):(M=c[P]=[i[h]],M.i=m,M.j=v,M.x=(m+(1&v?.5:0))*u,M.y=v*p)}var S=new l({max:n.max||100,maxSize:s,gradient:n.gradient});for(var r in c){var L=c[r];t.beginPath();for(var C=0;C<6;C++){var E=y({x:L.x+a.x,y:L.y+a.y},s,C);t.lineTo(E[0],E[1])}t.closePath();for(var T=0,h=0;h0&&(i+=t[o-1].length,n.holes.push(i))}return n};var Tt=["attribute vec4 a_Position;","void main() {","gl_Position = a_Position;","gl_PointSize = 30.0;","}"].join(""),jt=["precision mediump float;","uniform vec4 u_FragColor;","void main() {","gl_FragColor = u_FragColor;","}"].join(""),zt={draw:X},Rt={draw:function(t,e,n){var i=e instanceof o?e.get():e;i.length>0&&("LineString"==i[0].geometry.type?St.draw(t,i,n):"Polygon"==i[0].geometry.type||"MultiPolygon"==i[0].geometry.type?zt.draw(t,i,n):Et.draw(t,i,n))}},Dt={getPoints:K},Bt=function(){function t(t,e){return t.x*e.x+t.y*e.y}function e(t){return{x:O[t.target].x-O[t.source].x,y:O[t.target].y-O[t.source].y}}function n(t){return Math.sqrt(Math.pow(O[t.source].x-O[t.target].x,2)+Math.pow(O[t.source].y-O[t.target].y,2))}function i(t){return Math.sqrt(Math.pow(t.source.x-t.target.x,2)+Math.pow(t.source.y-t.target.y,2))}function o(t){return{x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2}}function r(t){for(var e=0,n=1;nB||Math.abs(s.y)>B){var l=1/Math.pow(i({source:S[r[a]][e],target:S[t][e]}),1);o.x+=s.x*l,o.y+=s.y*l}}return o}function f(t,e,i){for(var o=L/(n(k[t])*(e+1)),r=[{x:0,y:0}],a=1;as;){var c=s/p,h=S[e][u-1].x,f=S[e][u-1].y;h+=c*(S[e][u].x-S[e][u-1].x),f+=c*(S[e][u].y-S[e][u-1].y),l.push({x:h,y:f}),p-=s,s=i}s-=p}l.push(O[k[e].target]),S[e]=l}}function y(i,o){return Math.abs(t(e(i),e(o))/(n(i)*n(o)))}function v(t,e){var i=(n(t)+n(e))/2;return 2/(i/Math.min(n(t),n(e))+Math.max(n(t),n(e))/i)}function g(t,e){var i=(n(t)+n(e))/2;return i/(i+a({x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2},{x:(O[e.source].x+O[e.target].x)/2,y:(O[e.source].y+O[e.target].y)/2}))}function m(t,e){var n=s(O[e.source],{source:O[t.source],target:O[t.target]}),i=s(O[e.target],{source:O[t.source],target:O[t.target]}),o={x:(n.x+i.x)/2,y:(n.y+i.y)/2},r={x:(O[t.source].x+O[t.target].x)/2,y:(O[t.source].y+O[t.target].y)/2};return Math.max(0,1-2*a(r,o)/a(n,i))}function b(t,e){return Math.min(m(t,e),m(e,t))}function w(t,e){return y(t,e)*v(t,e)*g(t,e)*b(t,e)}function _(t,e){return w(t,e)>=D}function x(){for(var t=0;t=n.length-1));r++);this.splitList.other=n[n.length-1]},tt.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},et.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:w,_=f(w);for(u in o)if(void 0!==i[u]){var x=i[u]||0,O=o[u];O instanceof Array?n[u]=d(O,_):("string"==typeof O&&(O="+"===O.charAt(0)||"-"===O.charAt(0)?x+parseFloat(O):parseFloat(O)),"number"==typeof O&&(n[u]=x+(O-x)*_))}if(null!==m&&m.call(n,_),1===w){if(s>0){isFinite(s)&&s--;for(u in r){if("string"==typeof o[u]&&(r[u]=r[u]+parseFloat(o[u])),l){var k=r[u];r[u]=o[u],o[u]=k}i[u]=r[u]}return l&&(p=!p),h=void 0!==e?t+e:t+c,!0}null!==b&&b.call(n,n);for(var P=0,M=y.length;P1?r(t[n],t[n-1],n-i):r(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,r=Ft.Interpolation.Utils.Bernstein,a=0;a<=i;a++)n+=o(1-e,i-a)*o(e,a)*t[a]*r(i,a);return n},CatmullRom:function(t,e){var n=t.length-1,i=n*e,o=Math.floor(i),r=Ft.Interpolation.Utils.CatmullRom;return t[0]===t[n]?(e<0&&(o=Math.floor(i=n*(1+e))),r(t[(o-1+n)%n],t[o],t[(o+1)%n],t[(o+2)%n],i-o)):e<0?t[0]-(r(t[0],t[0],t[1],t[1],-i)-t[0]):e>1?t[n]-(r(t[n],t[n],t[n-1],t[n-1],i-n)-t[n]):r(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 r=.5*(n-t),a=.5*(i-e),s=o*o;return(2*e-2*n+r+a)*(o*s)+(-3*e+3*n-2*r-a)*s+r*o+e}}};var Nt={},Ut={draw:function(t,e,n){var i="http://huiyan.baidu.com/github/tools/gis-drawing/static/images/direction.png";n.arrow&&n.arrow.url&&(i=n.arrow.url),Nt[i]||(Nt[i]=null);var r=Nt[i];if(!r){var a=Array.prototype.slice.call(arguments),s=new Image;return s.onload=function(){Nt[i]=s,Ut.draw.apply(null,a)},void(s.src=i)}var l=e instanceof o?e.get():e;t.save();for(var u in n)t[u]=n[u];for(var p=[],c=null,h=0,f=l.length;h-1){if(t.isPointInStroke&&t.isPointInStroke(o,r))return n[i]}else if(t.isPointInPath(o,r))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:"update",value:function(t,e){var n=this,i=t.options,o=n.options;for(var r in i)o[r]=i[r];n.init(o),!1!==e&&n.draw()}},{key:"setOptions",value:function(t){var e=this;e.dataSet.reset(),e.init(t),e.draw()}},{key:"set",value:function(t){var e=this,n=this.getContext(),i=this.getDefaultContextConfig();for(var o in i)n[o]=i[o];e.init(t.options),e.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 Ft.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}(),Ht=function(t){function e(t,n,i){ft(this,e);var o=gt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i));o.map=t,o.options=i||{},o.dataSet=n;var r=new nt({map:t,zIndex:o.options.zIndex,update:o._canvasUpdate.bind(o)});o.init(o.options),o.canvasLayer=r,o.transferToMercator();var a=o;return n.on("change",function(){a.transferToMercator(),r.draw()}),o.ctx=r.canvas.getContext("2d"),o.start(),o}return vt(e,t),dt(e,[{key:"draw",value:function(){this.canvasLayer.draw()}},{key:"init",value:function(t){var e=this;e.options=t,this.initDataRange(t),this.context=e.options.context||"2d",e.options.zIndex&&this.canvasLayer&&this.canvasLayer.setZIndex(e.options.zIndex),e.options.max&&this.intensity.setMax(e.options.max),e.options.min&&this.intensity.setMin(e.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=this.map,n=Math.pow(2,18-e.getZoom()),i=e.getMapType().getProjection(),o=i.lngLatToPoint(e.getCenter()),r=new BMap.Pixel(o.x-e.getSize().width/2*n,o.y+e.getSize().height/2*n);ut(t);var a={fromColumn:"bd09mc"==this.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){if(t){return[(t[0]-r.x)/n,(r.y-t[1])/n]}}};this.data=this.dataSet.get(a),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=r),t.lineWidth=1,t.strokeStyle=e[i].strokeStyle||e[i]._strokeStyle||n.strokeStyle||"yellow",t.stroke();var a=e[i].fillStyle||e[i]._fillStyle||n.fillStyle;a&&(t.fillStyle=a,t.fill())}else if("LineString"===e[i].geometry.type){t.beginPath();var s=e[i].size||this.options.size||5,r=e[i].minSize||this.options.minSize||0;void 0===e[i]._index&&(e[i]._index=0);var l=e[i]._index;t.arc(e[i].geometry._coordinates[l][0],e[i].geometry._coordinates[l][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 u=e[i].strokeStyle||n.strokeStyle,a=e[i].fillStyle||n.fillStyle||"yellow";t.fillStyle=a,t.fill(),u&&n.lineWidth&&(t.lineWidth=n.lineWidth||1,t.strokeStyle=u,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()}}]),e}(Vt),Jt=function(t){function e(t,n,i){ft(this,e);var o=gt(this,(e.__proto__||Object.getPrototypeOf(e)).call(this,t,n,i)),r=o;i=i||{},o.clickEvent=o.clickEvent.bind(o),o.mousemoveEvent=o.mousemoveEvent.bind(o),r.init(i),r.argCheck(i),r.transferToMercator();var a=o.canvasLayer=new nt({map:t,context:o.context,paneName:i.paneName,mixBlendMode:i.mixBlendMode,enableMassClear:i.enableMassClear,zIndex:i.zIndex,update:function(){r._canvasUpdate()}});return n.on("change",function(){r.transferToMercator(),a.draw()}),o}return vt(e,t),dt(e,[{key:"clickEvent",value:function(t){var n=t.pixel;yt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"clickEvent",this).call(this,n,t)}},{key:"mousemoveEvent",value:function(t){var n=t.pixel;yt(e.prototype.__proto__||Object.getPrototypeOf(e.prototype),"mousemoveEvent",this).call(this,n,t)}},{key:"bindEvent",value:function(t){this.unbindEvent();var e=this.map;this.options.methods&&(this.options.methods.click&&(e.setDefaultCursor("default"),e.addEventListener("click",this.clickEvent)),this.options.methods.mousemove&&e.addEventListener("mousemove",this.mousemoveEvent))}},{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(){var t=this.map.getMapType().getProjection();if("bd09mc"!==this.options.coordType){var e=this.dataSet.get();e=this.dataSet.transferCoordinate(e,function(e){if(e[0]<-180||e[0]>180||e[1]<-90||e[1]>90)return e;var n=t.lngLatToPoint({lng:e[0],lat:e[1]});return[n.x,n.y]},"coordinates","coordinates_mercator"),this.dataSet._set(e)}}},{key:"getContext",value:function(){return this.canvasLayer.canvas.getContext(this.context)}},{key:"_canvasUpdate",value:function(t){if(this.canvasLayer){var e=this,n=e.options.animation,i=this.canvasLayer._map,o=Math.pow(2,18-i.getZoom()),r=i.getMapType().getProjection(),a=r.lngLatToPoint(i.getCenter()),s=new BMap.Pixel(a.x-i.getSize().width/2*o,a.y+i.getSize().height/2*o),l=this.getContext();if(e.isEnabledTime()){if(void 0===t)return void ut(l);"2d"==this.context&&(l.save(),l.globalCompositeOperation="destination-out",l.fillStyle="rgba(0, 0, 0, .1)",l.fillRect(0,0,l.canvas.width,l.canvas.height),l.restore())}else ut(l);if("2d"==this.context)for(var u in e.options)l[u]=e.options[u];else l.clear(l.COLOR_BUFFER_BIT);if(!(e.options.minZoom&&i.getZoom()e.options.maxZoom)){var p=1;"2d"!=this.context&&(p=this.canvasLayer.devicePixelRatio);var c={fromColumn:"bd09mc"==e.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){return[(t[0]-s.x)/o*p,(s.y-t[1])/o*p]}};void 0!==t&&(c.filter=function(e){var i=n.trails||10;return!!(t&&e.time>t-i&&e.timee.options.maxZoom)){var a=1;"2d"!=this.context&&(a=this.canvasLayer.devicePixelRatio);var s=this.map,l=s.getProjection(),a=Math.pow(2,s.zoom)*resolutionScale,u=l.fromLatLngToPoint(this.canvasLayer.getTopLeft()),p={transferCoordinate:function(t){var e=new google.maps.LatLng(t[1],t[0]),n=l.fromLatLngToPoint(e),i={x:(n.x-u.x)*a,y:(n.y-u.y)*a};return[i.x,i.y]}};void 0!==t&&(p.filter=function(e){var i=n.trails||10;return!!(t&&e.time>t-i&&e.timee-n&&t.time0&&void 0!==arguments[0]?arguments[0]:null,n=arguments[1],i=arguments[2];ft(this,e);var o=gt(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 vt(e,t),dt(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,i=t.getContext(this.context),r=this.options.animation;if(this.isEnabledTime()){if(void 0===e)return ut(i),this;"2d"===this.context&&(i.save(),i.globalCompositeOperation="destination-out",i.fillStyle="rgba(0, 0, 0, .1)",i.fillRect(0,0,i.canvas.width,i.canvas.height),i.restore())}else ut(i);if("2d"===this.context)for(var a in this.options)i[a]=this.options[a];else i.clear(i.COLOR_BUFFER_BIT);var s={transferCoordinate:function(t){var e=n.lngLatToContainer(new AMap.LngLat(t[0],t[1]));return[e.x,e.y]}};void 0!==e&&(s.filter=function(t){var n=r.trails||10;return!!(e&&t.time>e-n&&t.time0&&void 0!==arguments[0]?arguments[0]:null,n=arguments[1],i=arguments[2];ft(this,e);var o=gt(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 vt(e,t),dt(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,i=t.getContext(this.context),r=this.options.animation,a=this.options.hasOwnProperty("projection")?this.options.projection:"EPSG:4326";if(this.isEnabledTime()){if(void 0===e)return ut(i),this;"2d"===this.context&&(i.save(),i.globalCompositeOperation="destination-out",i.fillStyle="rgba(0, 0, 0, .1)",i.fillRect(0,0,i.canvas.width,i.canvas.height),i.restore())}else ut(i);if("2d"===this.context)for(var s in this.options)i[s]=this.options[s];else i.clear(i.COLOR_BUFFER_BIT);var l={transferCoordinate:function(t){return n.getPixelFromCoordinate(ol.proj.transform(t,a,"EPSG:4326"))}};void 0!==e&&(l.filter=function(t){var n=r.trails||10;return!!(e&&t.time>e-n&&t.time0&&!0===this.props.autoViewport&&t.setViewport(e,this.props.viewportOptions)}}},{key:"getOverlay",value:function(){return null}},{key:"options",get:function(){return["strokeColor","fillColor","strokeWeight","strokeOpacity","fillOpacity","strokeStyle","enableMassClear","enableEditing","enableClicking"]}},{key:"events",get:function(){return["click","dblclick","mousedown","mouseup","mouseout","mouseover","remove","lineupdate"]}}]),e}(l.default);e.default=u},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});for(var s=(function(){function t(t,e){for(var n=0;n-1&&(v=!1,r=r.replace(/-/,"")),r.indexOf("+")>-1&&(v=!0,r=r.replace("+","")),0==r.length&&(r="_"));var g={display:"flex",justifyContent:"space-between",background:"#FFFFFF",alignItems:"stretch",boxShadow:"0 2px 2px 0 rgba(0, 0, 0, 0.22)",borderRadius:"3px 0 0 3px",minWidth:"155px",minHeight:"50px",marginTop:"-25px"},m={minWidth:"30px",background:"#999999",color:"white",padding:"auto 0",display:"flex",justifyContent:"center",alignItems:"center"};this.props.active&&(m.background="#F5533D"),this.props.leftStyle&&(m=d.obj.merge(m,this.props.leftStyle)),this.props.style&&(g=d.obj.merge(g,this.props.style));var b={flex:"1",padding:"6px",justifyContent:"center",alignItems:"center",fontSize:"12px",color:"#8D93A3",letterSpacing:"0.6px"};this.props.rightStyle&&(b=d.obj.merge(b,this.props.rightStyle));var w=Object.keys(t.props).filter(function(t){return 0==t.indexOf("on")}),_=[];if(w.map(function(e){_.push(o({},e,t.props[e]))}),h)return c.default.createElement(f.default,{key:JSON.stringify(y)+Math.random(),map:this.props.map,position:y},c.default.createElement("div",l({key:JSON.stringify(y)+Math.random(),style:g},_),c.default.createElement("div",{style:m},u),c.default.createElement("div",{style:b},!s&&c.default.createElement("div",null," ",i+"("+r,v?c.default.createElement("img",{style:{width:"8px",height:"auto",margin:"1px"},src:"//huiyan.baidu.com/cms/react-bmap/up.png"}):c.default.createElement("img",{style:{width:"8px",height:"auto",margin:"1px"},src:"//huiyan.baidu.com/cms/react-bmap/down.png"}),")"),s||c.default.createElement("div",null," ",a," "))))}},{key:"render",value:function(){return this.createMarker()}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(c.default.Component);e.default=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=void 0,i=void 0;try{if("string"==typeof t){var o=t.split(",");n=JSON.parse(o[0].match(/[0-9]+\.?[0-9]{0,}/)[0]),i=JSON.parse(o[1].match(/[0-9]+\.?[0-9]{0,}/)[0])}else t instanceof Array?(n=JSON.parse(t[0]),i=JSON.parse(t[1])):t instanceof Object&&(n=t.lng,i=t.lat);if(e)return{lng:n,lat:i};return new BMap.Point(n,i)}catch(t){console.log("create BmapPoint error",'Please input data like this: 1. "114.54,40.33", 2.[114.54,40.33], 3.{lng:114.54,lat:40.33}')}};e.default=i},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}Object.defineProperty(e,"__esModule",{value:!0});var o=n(10);Object.defineProperty(e,"Map",{enumerable:!0,get:function(){return i(o).default}});var r=n(5);Object.defineProperty(e,"Marker",{enumerable:!0,get:function(){return i(r).default}});var a=n(7);Object.defineProperty(e,"MarkerOrderTip",{enumerable:!0,get:function(){return i(a).default}});var s=n(21);Object.defineProperty(e,"InfoWindow",{enumerable:!0,get:function(){return i(s).default}});var l=n(22);Object.defineProperty(e,"NavigationControl",{enumerable:!0,get:function(){return i(l).default}});var u=n(23);Object.defineProperty(e,"OverviewMapControl",{enumerable:!0,get:function(){return i(u).default}});var p=n(24);Object.defineProperty(e,"ScaleControl",{enumerable:!0,get:function(){return i(p).default}});var c=n(25);Object.defineProperty(e,"MapTypeControl",{enumerable:!0,get:function(){return i(c).default}});var h=n(26);Object.defineProperty(e,"PanoramaControl",{enumerable:!0,get:function(){return i(h).default}});var f=n(27);Object.defineProperty(e,"Circle",{enumerable:!0,get:function(){return i(f).default}});var d=n(28);Object.defineProperty(e,"Polyline",{enumerable:!0,get:function(){return i(d).default}});var y=n(29);Object.defineProperty(e,"Polygon",{enumerable:!0,get:function(){return i(y).default}});var v=n(30);Object.defineProperty(e,"Road",{enumerable:!0,get:function(){return i(v).default}});var g=n(34);Object.defineProperty(e,"Boundary",{enumerable:!0,get:function(){return i(g).default}});var m=n(35);Object.defineProperty(e,"MarkerList",{enumerable:!0,get:function(){return i(m).default}});var b=n(37);Object.defineProperty(e,"MapvMarkerList",{enumerable:!0,get:function(){return i(b).default}});var w=n(38);Object.defineProperty(e,"TrafficLayer",{enumerable:!0,get:function(){return i(w).default}});var _=n(39);Object.defineProperty(e,"Merge",{enumerable:!0,get:function(){return i(_).default}});var x=n(40);Object.defineProperty(e,"MapvLayer",{enumerable:!0,get:function(){return i(x).default}});var O=n(41);Object.defineProperty(e,"DrivingRoute",{enumerable:!0,get:function(){return i(O).default}});var k=n(42);Object.defineProperty(e,"PointLabel",{enumerable:!0,get:function(){return i(k).default}});var P=n(45);Object.defineProperty(e,"Arc",{enumerable:!0,get:function(){return i(P).default}});var M=n(46);Object.defineProperty(e,"ThickRay",{enumerable:!0,get:function(){return i(M).default}});var S=n(47);Object.defineProperty(e,"MapListener",{enumerable:!0,get:function(){return i(S).default}})},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n1&&void 0!==arguments[1])||arguments[1],n=[];return t.split("|").forEach(function(t){for(var i=t?t.split(","):[],r=[],a=0;a=200&&this.status<300?t.success&&t.success(JSON.parse(this.response)):t.fail&&t.fail(this.statusText),t.complete&&t.complete(JSON.parse(this.response)),clearTimeout(a)},n.onerror=function(){t.fail&&t.fail(e.statusText),clearTimeout(a)},{abort:function(){o||(o=!0,n.abort())},params:t}}function r(t){var e="jsonp_"+ +new Date+"_"+parseInt(1e7*Math.random(),10),n=document.createElement("script"),i=!1;t.url+="-1"===t.url.indexOf("?")?"?":"&",t.url+="callback="+e,n.src=t.url,document.head.appendChild(n);var o=setTimeout(function(){null!==window[e]&&(window[e]=null,n.parentElement.removeChild(n),t.fail&&t.fail({error:null,msg:"timeout"}),t.complete&&t.complete(JSON.parse()))},1e4);return n.addEventListener("error",function(r){window[e]=null,n.parentElement.removeChild(n),clearTimeout(o),i||(t.fail&&t.fail({error:r,msg:"loaderror"}),t.complete&&t.complete())}),window[e]=function(r){clearTimeout(o),i||(t.success(r),t.complete&&t.complete()),window[e]=null,n.parentElement.removeChild(n)},{abort:function(){clearTimeout(o),i=!0},params:t}}Object.defineProperty(e,"__esModule",{value:!0});var a={fetch:i,ajax:o,jsonp:r,test:function(){console.log("test kits-js http")}};e.default=a},function(t,e,n){"use strict";function i(t,e,n){this.options=n||{},this._point=t,this.content=e}Object.defineProperty(e,"__esModule",{value:!0}),i.prototype=new BMap.Overlay,i.prototype.initialize=function(t){this._map=t;var e=this._div=document.createElement("div");e.setAttribute("tag","customoverlay"),e.style.position="absolute";var n=this.options.zIndex||BMap.Overlay.getZIndex(this._point.lat);return e.style.zIndex=n,e.addEventListener("touchstart",function(t){t.stopPropagation(),console.log("touchstart")}),e.addEventListener("touchend",function(t){t.stopPropagation(),console.log("touchend")}),"[object String]"==Object.prototype.toString.call(this.content)?e.innerHTML=this.content:e.appendChild(this.content),t.getPanes().labelPane.appendChild(e),e},i.prototype.draw=function(){var t=this._map,e=t.pointToOverlayPixel(this._point),n=this.options.offset||new BMap.Size(0,0);this._div.style.left=e.x+n.width+"px",this._div.style.top=e.y+n.height+"px"},e.default=i},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==this.props.autoViewport&&this.props.map.setViewport(e,this.props.viewportOptions)}},{key:"getRoadGroup",value:function(t,e,n){var t=t,e=e,n=n,i={},o=[];if(e)for(var r=0;r1)for(var n=1;n3&&void 0!==arguments[3]?arguments[3]:{},r=t.getZoom(),a=o.lineWidth||5,s=void 0===o.level?1:o.level,l=null,u=0,p=0,c=[],h=[],f=[],d=0,y=0;e.beginPath();var v,g=Math.pow(2,18-t.getZoom()),m=t.getMapType().getProjection(),b=m.lngLatToPoint(t.getCenter()),w=new BMap.Pixel(b.x-t.getSize().width/2*g,b.y+t.getSize().height/2*g);return n.forEach(function(n,i){var r=null;l=null;for(var a=n.split(","),s=0;s=50&&(f.push(b),d%=50))}l=v,0===s?(r=r||v,e.moveTo(v.x,v.y)):(p>15||s>=a.length-2)&&(p=0,e.lineTo(v.x,v.y))}if(o.arrow&&i===n.length-1&&y<100){var O=c[Math.ceil(c.length/2)];for(var k in c)if(c[k].totalDepth>=y/2){O=c[k+1]?c[k+1]:c[k];break}var P=c[c.length-1];O.end=P.end,f=[],f.push(O)}}),o.line&&(e.lineCap=o.lineCap||"round",e.lineJoin="round",o.border&&(e.strokeStyle=o.border.color||"white",e.lineWidth=(r<=13?a-2:a)+(2*o.border.lineWidth||4),e.stroke()),e.strokeStyle=o.color||i[s]||"#fc2c2b",e.lineWidth=r<=13?a-2:a,e.stroke()),o.arrow&&this.drawArrow(e,f,o),h},drawArrow:function(t,e,n){t.beginPath(),e.forEach(function(i){var o=i.start.x,r=i.start.y,a=i.end.x,s=i.end.y,l=a-o,u=s-r,p=[0,-1],c=[i.end.x-i.start.x,i.end.y-i.start.y],h=p[0]*c[0]+p[1]*c[1],f=Math.sqrt(p[0]*p[0]+p[1]*p[1]),d=Math.sqrt(c[0]*c[0]+c[1]*c[1]),y=Math.acos(h/(f*d));c[0]<0&&(y=2*Math.PI-y);for(var v=n.arrow.width/2||2,g=n.arrow.height||v,m=0;i.offset+50*m<=i.depth;){var b=i.offset+50*m,w=b/i.depth;t.save(),t.translate(o+l*w,r+u*w),t.rotate(y),t.moveTo(1.618*-v,g),t.lineTo(0,0),t.lineTo(1.618*v,g),t.restore(),m+=1}1===e.length&&i.offset>i.depth&&(t.save(),t.translate(o,r),t.rotate(y),t.moveTo(1.618*-v,g),t.lineTo(0,0),t.lineTo(1.618*v,g),t.restore())}),t.strokeStyle=n.arrow.color||"#fff",t.lineWidth=3,t.stroke()}};e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={mergeRoadPath:function(t,e){for(var n=[],i=0;i=Math.min(o.lng,r.lng)&&t.lng<=Math.max(o.lng,r.lng)&&t.lat>=Math.min(o.lat,r.lat)&&t.lat<=Math.max(o.lat,r.lat)){var a=(o.lng-t.lng)*(r.lat-t.lat)-(r.lng-t.lng)*(o.lat-t.lat),s=2e-10;if(s=2e-9,a-s)return!0}}return!1}};e.default=i},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==i.props.autoViewport&&n.setViewport(o,i.props.viewportOptions)}}var e=this.props.data,n=this.props.map;if(e){this._request={};var i=this,o=new BMap.Boundary,r=[];e.forEach(function(t,e){i._request[t.name]=!1,i._backData[t.name]&&(r=r.concat(i._backData[t.name]),i._request[t.name]=!0)}),t(),e.forEach(function(e,n){i._request[e.name]||i._allRequest[e.name]||(i._allRequest[e.name]=!0,o.get(e.name,function(n){for(var o=[],a=0;a=10&&(n.isShowNumber=!1,n.size=10,n.strokeStyle=f,n.lineWidth=3,n.strokeOpacity=.4));var d=new h.default(n);d.addEventListener("click",function(e,n){t.props.onClick&&t.props.onClick(n-1)}),d.addEventListener("mouseover",function(e,n){t.props.onMouseOver&&t.props.onMouseOver(n-1)}),d.addEventListener("mouseout",function(e,n){t.props.onMouseOut&&t.props.onMouseOut(n-1)}),d.index=l,this.markers.push(d),s.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:a[l].count,text:a[l].text})}for(var y=this.markers.length;y--;)e.addOverlay(this.markers[y]);this.dataSet.set(s.splice(0,10)),this.setViewport()}}},{key:"setViewport",value:function(){var t=this.props.map;if(t){for(var e=this.props.data,n=t.getMapType().getProjection(),i=[],o=0;o0&&!1!==this.props.autoViewport&&t.setViewport(i,this.props.viewportOptions)}}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(u.default);e.default=f},function(t,e,n){"use strict";function i(t){this.options=t||{},this._point=t.point,this._fillColor=t.fillStyle||"#1495ff",this._size=t.size||30,this._lineWidth=void 0===t.lineWidth?2:t.lineWidth,this._strokeStyle=t.strokeStyle||"#ffffff",t.strokeOpacity&&(this._strokeStyle=o(this._strokeStyle,.4))}function o(t,e){var n=/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/,i=t.toLowerCase();if(i&&n.test(i)){if(4===i.length){for(var o="#",r=1;r<4;r+=1)o+=i.slice(r,r+1).concat(i.slice(r,r+1));i=o}for(var a=[],r=1;r<7;r+=2)a.push(parseInt("0x"+i.slice(r,r+2)));return e?(a.push(e),"rgba("+a.join(",")+")"):"rgb("+a.join(",")+")"}return i}Object.defineProperty(e,"__esModule",{value:!0}),i.prototype=new BMap.Overlay,i.prototype.initialize=function(t){this._map=t;var e=this._div=document.createElement("div"),n=e.style;n.position="absolute",n.backgroundClip="padding-box",n.zIndex=this.options.zIndex||BMap.Overlay.getZIndex(this._point.lat),n.backgroundColor=this._fillColor,!1!==this.options.isShowShadow&&(n.boxShadow="0 0 5px rgba(0, 0, 0, 0.5)"),n.border=this._lineWidth+"px solid "+this._strokeStyle,n.color="white",n.textShadow="0px 0px 5px #fff",n.width=this._size+"px",n.boxSizing="content-box",n.borderRadius="30px",n.height=this._size+"px",n.lineHeight=this._size+"px",n.fontSize="12px",n.cursor="pointer",n.textAlign="center",n.MozUserSelect="none",this.options.number&&!1!==this.options.isShowNumber&&(e.innerHTML=this.options.number);var i=this;return e.addEventListener("mouseover",function(){i.dispatchEvent("mouseover",i.options.number),n.backgroundColor="#1495ff"}),e.addEventListener("mouseout",function(){i.dispatchEvent("mouseout",i.options.number),n.backgroundColor=i._fillColor}),e.addEventListener("click",function(){i.dispatchEvent("click",i.options.number)}),t.getPanes().markerPane.appendChild(e),e},i.prototype.draw=function(){var t=this._map,e=t.pointToOverlayPixel(this._point);this._div.style.left=e.x-(this._size+this._lineWidth)/2+1+"px",this._div.style.top=e.y-(this._size+this._lineWidth)/2+"px"},e.default=i},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&(t.forEach(function(t,l){var u=t.location.split(","),p=e.project.pointToLngLat(new BMap.Pixel(u[0],u[1]));s.push(p),l<10?(n.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count)}),i.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},id:l,count:parseInt(t.count),text:parseInt(l)+1}),o.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count),text:t.text})):(r.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},id:l,count:parseInt(t.count)}),a.push({geometry:{type:"Point",coordinates:[u[0],u[1]]},count:parseInt(t.count)}))}),this.shadowSet.set(n),this.circleSet.set(i),this.textSet.set(o),this.numSet.set(i),this.otherSet.set(r),this.otherShadowSet.set(a),s.length>0&&!1!==this.props.autoViewport&&map.setViewport(s,self.props.viewportOptions))}},{key:"createLayers",value:function(){this._createLayer=!0;var t=this.map;this.project=t.getMapType().getProjection();var e=this,n=this.shadowSet=new u.DataSet([]),i=this.circleSet=new u.DataSet([]),o=this.textSet=new u.DataSet([]),r=this.numSet=new u.DataSet([]),a=this.otherSet=new u.DataSet([]),s=this.otherShadowSet=new u.DataSet([]);this.layers=[];var l={coordType:"bd09mc",splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",other:"#80db69"},shadowBlur:10,size:5,max:30,methods:{click:function(t){t&&e.handleClick(t.id)},mousemove:function(t){a.update(function(t){t.fillStyle=null}),t?(e.isSmallPath=!0,e.props.map.setDefaultCursor("pointer"),a.update(function(t){t.fillStyle="#1495ff"},{id:t.id})):(e.isSmallPath=!1,e.isSmallPath||e.isBigPath||e.props.map.setDefaultCursor("auto"))}},draw:"category"},p={splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",1:"#80db69"},styleType:"fill",globalAlpha:.4,coordType:"bd09mc",size:8,minSize:5,draw:"category"};if(this.layers.push(new u.baiduMapLayer(t,s,p)),this.layers.push(new u.baiduMapLayer(t,a,l)),!0===this.props.animation){var c={splitList:{4:"#d53938",3:"#fe6261",2:"#ffb02d",1:"#80db69"},styleType:"stroke",globalAlpha:.4,coordType:"bd09mc",size:20,minSize:10,draw:"category"};this.layers.push(new u.baiduMapAnimationLayer(t,n,c))}var h={splitList:{1:"#80db69",4:"#d53938",3:"#fe6261",2:"#ffb02d"},fillStyle:"red",coordType:"bd09mc",size:10,draw:"category",methods:{click:function(t){t&&e.handleClick(t.id)},mousemove:function(t){i.update(function(t){t.fillStyle=null}),t?(e.isBigPath=!0,e.map.setDefaultCursor("pointer"),i.update(function(t){t.fillStyle="#1495ff"},{id:t.id})):(e.isBigPath=!1,e.isBigPath||e.isSmallPath||e.map.setDefaultCursor("auto"))}}};this.layers.push(new u.baiduMapLayer(t,i,h));var f={coordType:"bd09mc",draw:"text",font:"13px Arial",fillStyle:"#ffffff",shadowColor:"#ffffff",shadowBlur:10};this.layers.push(new u.baiduMapLayer(t,r,f));var d={coordType:"bd09mc",font:"13px Arial",fillStyle:"#666",shadowColor:"#ffffff",shadowBlur:10,draw:"text",avoid:!0,textAlign:"left",offset:{x:10,y:0}};this.layers.push(new u.baiduMapLayer(t,o,d))}},{key:"render",value:function(){return null}}],[{key:"defaultProps",get:function(){return{autoViewport:!0}}}]),e}(l.default);e.default=p},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;nthis.minX&&t.lat>this.minY&&t.lngthis.minX&&t.minY>this.minY&&t.maxX=Math.min(o.lng,r.lng)&&t.lng<=Math.max(o.lng,r.lng)&&t.lat>=Math.min(o.lat,r.lat)&&t.lat<=Math.max(o.lat,r.lat)){var a=(o.lng-t.lng)*(r.lat-t.lat)-(r.lng-t.lng)*(o.lat-t.lat),s=2e-10;if(s=2e-9,a-s)return!0}}return!1},e.default=o},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}Object.defineProperty(e,"__esModule",{value:!0});var a=function(){function t(t,e){for(var n=0;n0&&!1!==t.props.autoViewport&&e.setViewport(o,t.props.viewportOptions)})}this.lineDataSet.set(n),this.lineLayer.update({options:this.props.lineOptions||{draw:"simple",strokeStyle:"#5E87DB",lineWidth:3}}),this.pointDataSet.set(i),this.pointLayer.update({options:this.props.pointOptions||{coordType:this.props.coordType,draw:"simple",fillStyle:"#5E87DB",size:5}}),this.textLayer.update({options:this.props.textOptions||{coordType:this.props.coordType,draw:"text",font:"18px Arial",offset:{x:0,y:12},fillStyle:"#333",size:12}}),this.props.enableAnimation?this.animationLayer.update({options:this.props.animationOptions||{coordType:this.props.coordType,fillStyle:"rgba(255, 250, 250, 0.9)",lineWidth:0,size:4,animateTime:50,draw:"simple"}}):this.animationLayer&&this.animationLayer.hide()}}}],[{key:"defaultProps",get:function(){return{}}}]),e}(p.default);e.default=h},function(t,e,n){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function a(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)}Object.defineProperty(e,"__esModule",{value:!0});var s=function(){function t(t,e){for(var n=0;n0&&!1!==t.props.autoViewport&&e.setViewport(o,t.props.viewportOptions)})}this.lineDataSet.set(n),this.lineLayer.update({options:this.props.lineOptions||{coordType:this.props.coordType,draw:"simple",strokeStyle:"#5E87DB",globalCompositeOperation:"lighter",shadowColor:"rgba(255, 255, 255, 0.5)",shadowBlur:60,lineWidth:2}}),this.pointDataSet.set(i),this.pointLayer.update({options:this.props.pointOptions||{coordType:this.props.coordType,draw:"simple",fillStyle:"#5E87DB",size:5,shadowColor:"#5E87DB",shadowBlur:20}}),this.textLayer.update({options:this.props.textOptions||{coordType:this.props.coordType,draw:"text",font:"18px Arial",offset:{x:0,y:12},fillStyle:"#333",size:12}})}}}],[{key:"defaultProps",get:function(){return{}}}]),e}(p.default);e.default=h},function(t,e,n){"use strict";function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function r(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)}function a(t,e){var n=null;return function(){var i=this,o=arguments;n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,o)},e)}}function s(t,e){var n=void 0,i=arguments,o=void 0;return function r(){var a=this,s=Date.now();o||(o=s),n&&clearTimeout(n),s-o>=e?(t.apply(a,i),o=s):n=setTimeout(function(){r.apply(a,i)},50)}}Object.defineProperty(e,"__esModule",{value:!0});var l=function(){function t(t,e){for(var n=0;n= jMin && j <= jMax) { + pixels[i - 3] = gradient[j]; + pixels[i - 2] = gradient[j + 1]; + pixels[i - 1] = gradient[j + 2]; + } else { + pixels[i] = 0; + } } } -function drawGray(context, dataSet, options) { - +function getMax(options) { var max = options.max || 100; + return max; +} + +function getMin(options) { var min = options.min || 0; + return min; +} + +function drawGray(context, dataSet, options) { + + var max = getMax(options); + var min = getMin(options); // console.log(max) var size = options._size; if (size == undefined) { @@ -4364,6 +4431,7 @@ function getCurvePoints(points, options) { * @param Point 终点 */ function getCurveByTwoPoints(obj1, obj2, count) { + console.info(obj1, obj2); if (!obj1 || !obj2) { return null; } @@ -4404,22 +4472,18 @@ function getCurveByTwoPoints(obj1, obj2, count) { if (parseFloat(lng2 - lng1) > 180) { if (lng1 < 0) { lng1 = parseFloat(180 + 180 + lng1); - } - } - } - - if (lng1 > lng2) { - if (parseFloat(lng1 - lng2) > 180) { - if (lng2 < 0) { lng2 = parseFloat(180 + 180 + lng2); } } } + // 此时纠正了 lng1 lng2 j = 0; t2 = 0; + // 纬度相同 if (lat2 == lat1) { t = 0; h = lng1 - lng2; + // 经度相同 } else if (lng2 == lng1) { t = Math.PI / 2; h = lat1 - lat2; @@ -4435,7 +4499,12 @@ function getCurveByTwoPoints(obj1, obj2, count) { lat3 = h2 * Math.sin(t2) + lat1; for (i = 0; i < count + 1; i++) { - curveCoordinates.push([lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc), lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc)]); + var x = lng1 * B1(inc) + lng3 * B2(inc) + lng2 * B3(inc); + var y = lat1 * B1(inc) + lat3 * B2(inc) + lat2 * B3(inc); + var lng1_src = obj1.lng; + var lng2_src = obj2.lng; + + curveCoordinates.push([lng1_src < 0 && lng2_src > 0 ? x - 360 : x, y]); inc = inc + 1 / count; } return curveCoordinates; @@ -5101,6 +5170,11 @@ if (global$3.BMap) { that.adjustSize(); that._draw(); }); + /* + map.addEventListener('moving', function() { + that._draw(); + }); + */ return this.canvas; }; @@ -5945,6 +6019,151 @@ TWEEN.Interpolation = { }; +/** + * 根据2点获取角度 + * @param Array [123, 23] 点1 + * @param Array [123, 23] 点2 + * @return angle 角度,不是弧度 + */ +function getAngle(start, end) { + var diff_x = end[0] - start[0]; + var diff_y = end[1] - start[1]; + var deg = 360 * Math.atan(diff_y / diff_x) / (2 * Math.PI); + if (end[0] < start[0]) { + deg = deg + 180; + } + return deg; +} + +/** + * 绘制沿线箭头 + * @author kyle / http://nikai.us/ + */ + +var imageCache = {}; + +var object = { + draw: function draw(context, dataSet, options) { + var imageCacheKey = 'http://huiyan.baidu.com/github/tools/gis-drawing/static/images/direction.png'; + if (options.arrow && options.arrow.url) { + imageCacheKey = options.arrow.url; + } + + if (!imageCache[imageCacheKey]) { + imageCache[imageCacheKey] = null; + } + + var directionImage = imageCache[imageCacheKey]; + + if (!directionImage) { + var args = Array.prototype.slice.call(arguments); + var image = new Image(); + image.onload = function () { + imageCache[imageCacheKey] = image; + object.draw.apply(null, args); + }; + image.src = imageCacheKey; + return; + } + + var data = dataSet instanceof DataSet ? dataSet.get() : dataSet; + + // console.log('xxxx',options) + context.save(); + + for (var key in options) { + context[key] = options[key]; + } + + var points = []; + var preCoordinate = null; + for (var i = 0, len = data.length; i < len; i++) { + + var item = data[i]; + + context.save(); + + if (item.fillStyle || item._fillStyle) { + context.fillStyle = item.fillStyle || item._fillStyle; + } + + if (item.strokeStyle || item._strokeStyle) { + context.strokeStyle = item.strokeStyle || item._strokeStyle; + } + + var type = item.geometry.type; + + context.beginPath(); + if (type === 'LineString') { + var coordinates = item.geometry._coordinates || item.geometry.coordinates; + var interval = options.arrow.interval !== undefined ? options.arrow.interval : 1; + for (var j = 0; j < coordinates.length; j += interval) { + if (coordinates[j] && coordinates[j + 1]) { + var coordinate = coordinates[j]; + + if (preCoordinate && getDistance(coordinate, preCoordinate) < 30) { + continue; + } + + context.save(); + var angle = getAngle(coordinates[j], coordinates[j + 1]); + context.translate(coordinate[0], coordinate[1]); + context.rotate(angle * Math.PI / 180); + context.drawImage(directionImage, -directionImage.width / 2 / 2, -directionImage.height / 2 / 2, directionImage.width / 2, directionImage.height / 2); + context.restore(); + + points.push(coordinate); + preCoordinate = coordinate; + } + } + } + + context.restore(); + } + + context.restore(); + } +}; + +function getDistance(coordinateA, coordinateB) { + return Math.sqrt(Math.pow(coordinateA[0] - coordinateB[0], 2) + Math.pow(coordinateA[1] - coordinateB[1], 2)); +} + +/** + * @author Mofei Zhu + * This file is to draw text + */ + +var drawClip = { + draw: function draw(context, dataSet, options) { + var data = dataSet instanceof DataSet ? dataSet.get() : dataSet; + context.save(); + + context.fillStyle = options.fillStyle || 'rgba(0, 0, 0, 0.5)'; + context.fillRect(0, 0, context.canvas.width, context.canvas.height); + + options.multiPolygonDraw = function () { + context.save(); + context.clip(); + clear(context); + context.restore(); + }; + + for (var i = 0, len = data.length; i < len; i++) { + + context.beginPath(); + + pathSimple.drawDataSet(context, [data[i]], options); + context.save(); + context.clip(); + clear(context); + context.restore(); + } + + context.restore(); + } +}; + /** * @author Mofei Zhu * This file is to draw text @@ -6271,15 +6490,7 @@ var BaseLayer = function () { drawIcon.draw(context, dataSet, self.options); break; case 'clip': - context.save(); - context.fillStyle = self.options.fillStyle || 'rgba(0, 0, 0, 0.5)'; - context.fillRect(0, 0, context.canvas.width, context.canvas.height); - drawSimple.draw(context, dataSet, self.options); - context.beginPath(); - pathSimple.drawDataSet(context, dataSet, self.options); - context.clip(); - clear(context); - context.restore(); + drawClip.draw(context, dataSet, self.options); break; default: if (self.options.context == "webgl") { @@ -6288,6 +6499,10 @@ var BaseLayer = function () { drawSimple.draw(context, dataSet, self.options); } } + + if (self.options.arrow && self.options.arrow.show !== false) { + object.draw(context, dataSet, self.options); + } } }, { key: "isPointInPath", @@ -6299,15 +6514,25 @@ var BaseLayer = function () { pathSimple.draw(context, data[i], this.options); var x = pixel.x * this.canvasLayer.devicePixelRatio; var y = pixel.y * this.canvasLayer.devicePixelRatio; - if (context.isPointInPath(x, y) || context.isPointInStroke(x, y)) { - return data[i]; + + var geoType = data[i].geometry && data[i].geometry.type; + if (geoType.indexOf('LineString') > -1) { + if (context.isPointInStroke && context.isPointInStroke(x, y)) { + return data[i]; + } + } else { + if (context.isPointInPath(x, y)) { + return data[i]; + } } } } }, { key: "clickEvent", value: function clickEvent(pixel, e) { - + if (!this.options.methods) { + return; + } var dataItem = this.isPointInPath(this.getContext(), pixel); if (dataItem) { @@ -6319,6 +6544,9 @@ var BaseLayer = function () { }, { key: "mousemoveEvent", value: function mousemoveEvent(pixel, e) { + if (!this.options.methods) { + return; + } var dataItem = this.isPointInPath(this.getContext(), pixel); if (dataItem) { this.options.methods.mousemove(dataItem, e); @@ -6761,11 +6989,15 @@ var Layer = function (_BaseLayer) { if (this.options.coordType !== 'bd09mc') { var data = this.dataSet.get(); data = this.dataSet.transferCoordinate(data, function (coordinates) { - var pixel = projection.lngLatToPoint({ - lng: coordinates[0], - lat: coordinates[1] - }); - return [pixel.x, pixel.y]; + if (coordinates[0] < -180 || coordinates[0] > 180 || coordinates[1] < -90 || coordinates[1] > 90) { + return coordinates; + } else { + var pixel = projection.lngLatToPoint({ + lng: coordinates[0], + lat: coordinates[1] + }); + return [pixel.x, pixel.y]; + } }, 'coordinates', 'coordinates_mercator'); this.dataSet._set(data); } @@ -7513,175 +7745,1155 @@ var Layer$2 = function (_BaseLayer) { value: function bindEvent(e) { var map = this.map; - if (this.options.methods) { - if (this.options.methods.click) { - map.setDefaultCursor("default"); - map.addListener('click', this.clickEvent); - } - if (this.options.methods.mousemove) { - map.addListener('mousemove', this.mousemoveEvent); - } - } + if (this.options.methods) { + if (this.options.methods.click) { + map.setDefaultCursor("default"); + map.addListener('click', this.clickEvent); + } + if (this.options.methods.mousemove) { + map.addListener('mousemove', this.mousemoveEvent); + } + } + } + }, { + key: "unbindEvent", + value: function unbindEvent(e) { + var map = this.map; + + if (this.options.methods) { + if (this.options.methods.click) { + map.removeListener('click', this.clickEvent); + } + if (this.options.methods.mousemove) { + map.removeListener('mousemove', this.mousemoveEvent); + } + } + } + }, { + key: "getContext", + value: function getContext() { + return this.canvasLayer.canvas.getContext(this.context); + } + }, { + key: "_canvasUpdate", + value: function _canvasUpdate(time) { + if (!this.canvasLayer) { + return; + } + + var self = this; + + var animationOptions = self.options.animation; + + var context = this.getContext(); + + if (self.isEnabledTime()) { + if (time === undefined) { + clear(context); + return; + } + if (this.context == '2d') { + context.save(); + context.globalCompositeOperation = 'destination-out'; + context.fillStyle = 'rgba(0, 0, 0, .1)'; + context.fillRect(0, 0, context.canvas.width, context.canvas.height); + context.restore(); + } + } else { + clear(context); + } + + if (this.context == '2d') { + for (var key in self.options) { + context[key] = self.options[key]; + } + } else { + context.clear(context.COLOR_BUFFER_BIT); + } + + if (self.options.minZoom && map.getZoom() < self.options.minZoom || self.options.maxZoom && map.getZoom() > self.options.maxZoom) { + return; + } + + var scale = 1; + if (this.context != '2d') { + scale = this.canvasLayer.devicePixelRatio; + } + + var map = this.map; + var mapProjection = map.getProjection(); + var scale = Math.pow(2, map.zoom) * resolutionScale; + var offset = mapProjection.fromLatLngToPoint(this.canvasLayer.getTopLeft()); + var dataGetOptions = { + //fromColumn: self.options.coordType == 'bd09mc' ? 'coordinates' : 'coordinates_mercator', + transferCoordinate: function transferCoordinate(coordinate) { + var latLng = new google.maps.LatLng(coordinate[1], coordinate[0]); + var worldPoint = mapProjection.fromLatLngToPoint(latLng); + var pixel = { + x: (worldPoint.x - offset.x) * scale, + y: (worldPoint.y - offset.y) * scale + }; + return [pixel.x, pixel.y]; + } + }; + + if (time !== undefined) { + dataGetOptions.filter = function (item) { + var trails = animationOptions.trails || 10; + if (time && item.time > time - trails && item.time < time) { + return true; + } else { + return false; + } + }; + } + + // get data from data set + var data = self.dataSet.get(dataGetOptions); + + this.processData(data); + + var latLng = new google.maps.LatLng(0, 0); + var worldPoint = mapProjection.fromLatLngToPoint(latLng); + var pixel = { + x: (worldPoint.x - offset.x) * scale, + y: (worldPoint.y - offset.y) * scale + }; + + if (self.options.unit == 'm' && self.options.size) { + self.options._size = self.options.size / zoomUnit; + } else { + self.options._size = self.options.size; + } + + this.drawContext(context, new DataSet(data), self.options, pixel); + + //console.timeEnd('draw'); + + //console.timeEnd('update') + self.options.updateCallback && self.options.updateCallback(time); + } + }, { + key: "init", + value: function init(options) { + + var self = this; + + self.options = options; + + this.initDataRange(options); + + this.context = self.options.context || '2d'; + + if (self.options.zIndex) { + this.canvasLayer && this.canvasLayer.setZIndex(self.options.zIndex); + } + + this.initAnimator(); + } + }, { + key: "addAnimatorEvent", + value: function addAnimatorEvent() { + this.map.addListener('movestart', this.animatorMovestartEvent.bind(this)); + this.map.addListener('moveend', this.animatorMoveendEvent.bind(this)); + } + }, { + key: "show", + value: function show() { + this.map.addOverlay(this.canvasLayer); + } + }, { + key: "hide", + value: function hide() { + this.map.removeOverlay(this.canvasLayer); + } + }, { + key: "draw", + value: function draw() { + self.canvasLayer.draw(); + } + }]); + return Layer; +}(BaseLayer); + +/** + * MapV for maptalks.js (https://github.com/maptalks/maptalks.js) + * @author fuzhenn / https://github.com/fuzhenn + */ +// import * as maptalks from 'maptalks'; +var Layer$4 = void 0; +if (typeof maptalks !== 'undefined') { + Layer$4 = function (_maptalks$Layer) { + inherits(Layer, _maptalks$Layer); + + function Layer(id, dataSet, options) { + classCallCheck(this, Layer); + + var _this = possibleConstructorReturn(this, (Layer.__proto__ || Object.getPrototypeOf(Layer)).call(this, id, options)); + + _this.options_ = options; + _this.dataSet = dataSet; + _this._initBaseLayer(options); + return _this; + } + + createClass(Layer, [{ + key: "_initBaseLayer", + value: function _initBaseLayer(options) { + var self = this; + var baseLayer = this.baseLayer = new BaseLayer(null, this.dataSet, options); + self.init(options); + baseLayer.argCheck(options); + } + }, { + key: "clickEvent", + value: function clickEvent(e) { + if (!this.baseLayer) { + return; + } + var pixel = e.containerPoint; + this.baseLayer.clickEvent(pixel, e.domEvent); + } + }, { + key: "mousemoveEvent", + value: function mousemoveEvent(e) { + if (!this.baseLayer) { + return; + } + var pixel = e.containerPoint; + this.baseLayer.mousemoveEvent(pixel, e.domEvent); + } + }, { + key: "getEvents", + value: function getEvents() { + return { + 'click': this.clickEvent, + 'mousemove': this.mousemoveEvent + }; + } + }, { + key: "init", + value: function init(options) { + + var base = this.baseLayer; + + base.options = options; + + base.initDataRange(options); + + base.context = base.options.context || '2d'; + + base.initAnimator(); + } + }, { + key: "addAnimatorEvent", + value: function addAnimatorEvent() { + this.map.addListener('movestart', this.animatorMovestartEvent.bind(this)); + this.map.addListener('moveend', this.animatorMoveendEvent.bind(this)); + } + }]); + return Layer; + }(maptalks.Layer); + + var LayerRenderer = function (_maptalks$renderer$Ca) { + inherits(LayerRenderer, _maptalks$renderer$Ca); + + function LayerRenderer() { + classCallCheck(this, LayerRenderer); + return possibleConstructorReturn(this, (LayerRenderer.__proto__ || Object.getPrototypeOf(LayerRenderer)).apply(this, arguments)); + } + + createClass(LayerRenderer, [{ + key: "needToRedraw", + value: function needToRedraw() { + var base = this.layer.baseLayer; + if (base.isEnabledTime()) { + return true; + } + return get(LayerRenderer.prototype.__proto__ || Object.getPrototypeOf(LayerRenderer.prototype), "needToRedraw", this).call(this); + } + }, { + key: "draw", + value: function draw() { + var base = this.layer.baseLayer; + if (!this.canvas || !base.isEnabledTime() || this._shouldClear) { + this.prepareCanvas(); + this._shouldClear = false; + } + this._update(this.gl || this.context, this._mapvFrameTime); + delete this._mapvFrameTime; + this.completeRender(); + } + }, { + key: "drawOnInteracting", + value: function drawOnInteracting() { + this.draw(); + this._shouldClear = false; + } + }, { + key: "onSkipDrawOnInteracting", + value: function onSkipDrawOnInteracting() { + this._shouldClear = true; + } + }, { + key: "_canvasUpdate", + value: function _canvasUpdate(time) { + this.setToRedraw(); + this._mapvFrameTime = time; + } + }, { + key: "_update", + value: function _update(context, time) { + if (!this.canvas) { + return; + } + + var self = this.layer.baseLayer; + + var animationOptions = self.options.animation; + + var map = this.getMap(); + + if (self.isEnabledTime()) { + if (time === undefined) { + clear(context); + return; + } + if (self.context == '2d') { + context.save(); + context.globalCompositeOperation = 'destination-out'; + context.fillStyle = 'rgba(0, 0, 0, .1)'; + context.fillRect(0, 0, context.canvas.width, context.canvas.height); + context.restore(); + } + } else { + clear(context); + } + + if (self.context == '2d') { + for (var key in self.options) { + context[key] = self.options[key]; + } + } else { + context.clear(context.COLOR_BUFFER_BIT); + } + + var scale = 1; + if (self.context === '2d' && self.options.draw !== 'heatmap') { + //in heatmap.js, devicePixelRatio is being mulitplied independently + scale = self.canvasLayer.devicePixelRatio; + } + + //reuse to save coordinate instance creation + var coord = new maptalks.Coordinate(0, 0); + var dataGetOptions = { + fromColumn: self.options.coordType === 'bd09mc' ? 'coordinates_mercator' : 'coordinates', + transferCoordinate: function transferCoordinate(coordinate) { + coord.x = coordinate[0]; + coord.y = coordinate[1]; + var r = map.coordToContainerPoint(coord)._multi(scale).toArray(); + return r; + } + }; + + if (time !== undefined) { + dataGetOptions.filter = function (item) { + var trails = animationOptions.trails || 10; + if (time && item.time > time - trails && item.time < time) { + return true; + } else { + return false; + } + }; + } + + // get data from data set + var data = self.dataSet.get(dataGetOptions); + + self.processData(data); + + if (self.options.unit == 'm') { + if (self.options.size) { + self.options._size = self.options.size / zoomUnit; + } + if (self.options.width) { + self.options._width = self.options.width / zoomUnit; + } + if (self.options.height) { + self.options._height = self.options.height / zoomUnit; + } + } else { + self.options._size = self.options.size; + self.options._height = self.options.height; + self.options._width = self.options.width; + } + + var zeroZero = new maptalks.Point(0, 0); + //screen position of the [0, 0] point + var zeroZeroScreen = map._pointToContainerPoint(zeroZero)._multi(scale); + self.drawContext(context, data, self.options, zeroZeroScreen); + + //console.timeEnd('draw'); + + //console.timeEnd('update') + self.options.updateCallback && self.options.updateCallback(time); + } + }, { + key: "createCanvas", + value: function createCanvas() { + if (this.canvas) { + return; + } + var map = this.getMap(); + var size = map.getSize(); + var r = maptalks.Browser.retina ? 2 : 1, + w = r * size.width, + h = r * size.height; + this.canvas = maptalks.Canvas.createCanvas(w, h, map.CanvasClass); + var mapvContext = this.layer.baseLayer.context; + if (mapvContext === '2d') { + this.context = this.canvas.getContext('2d'); + if (this.layer.options['globalCompositeOperation']) { + this.context.globalCompositeOperation = this.layer.options['globalCompositeOperation']; + } + } else { + var attributes = { + 'alpha': true, + 'preserveDrawingBuffer': true, + 'antialias': false + }; + this.gl = this.canvas.getContext('webgl', attributes); + } + + this.onCanvasCreate(); + + this._bindToMapv(); + + this.layer.fire('canvascreate', { + 'context': this.context, + 'gl': this.gl + }); + } + }, { + key: "_bindToMapv", + value: function _bindToMapv() { + //some bindings needed by mapv baselayer + var base = this.layer.baseLayer; + this.devicePixelRatio = maptalks.Browser.retina ? 2 : 1; + base.canvasLayer = this; + base._canvasUpdate = this._canvasUpdate.bind(this); + base.getContext = function () { + var renderer = self.getRenderer(); + return renderer.gl || renderer.context; + }; + } + }]); + return LayerRenderer; + }(maptalks.renderer.CanvasRenderer); + + Layer$4.registerRenderer('canvas', LayerRenderer); +} + +var Layer$5 = Layer$4; + +/** + * MapV for AMap + * @author sakitam-fdd - https://github.com/sakitam-fdd + */ + +/** + * create canvas + * @param width + * @param height + * @param Canvas + * @returns {HTMLCanvasElement} + */ +var createCanvas = function createCanvas(width, height, Canvas) { + if (typeof document !== 'undefined') { + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + return canvas; + } else { + // create a new canvas instance in node.js + // the canvas class needs to have a default constructor without any parameter + return new Canvas(width, height); + } +}; + +var Layer$6 = function (_BaseLayer) { + inherits(Layer, _BaseLayer); + + function Layer() { + var map = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var dataSet = arguments[1]; + var options = arguments[2]; + classCallCheck(this, Layer); + + var _this = possibleConstructorReturn(this, (Layer.__proto__ || Object.getPrototypeOf(Layer)).call(this, map, dataSet, options)); + + _this.options = options; + + /** + * internal + * @type {{canvas: null, devicePixelRatio: number}} + */ + _this.canvasLayer = { + canvas: null, + devicePixelRatio: window.devicePixelRatio + }; + + /** + * canvas layer + * @type {null} + * @private + */ + _this.layer_ = null; + + _this.initDataRange(options); + _this.initAnimator(); + _this.onEvents(); + map.on('complete', function () { + this.init(map, options); + this.argCheck(options); + }, _this); + return _this; + } + + /** + * init mapv layer + * @param map + * @param options + */ + + + createClass(Layer, [{ + key: "init", + value: function init(map, options) { + if (map) { + this.map = map; + this.context = this.options.context || '2d'; + this.getCanvasLayer(); + } else { + throw new Error('not map object'); + } + } + + /** + * update layer + * @param time + * @private + */ + + }, { + key: "_canvasUpdate", + value: function _canvasUpdate(time) { + this.render(this.canvasLayer.canvas, time); + } + + /** + * render layer + * @param canvas + * @param time + * @returns {Layer} + */ + + }, { + key: "render", + value: function render(canvas, time) { + if (!canvas) return; + var map = this.map; + var context = canvas.getContext(this.context); + var animationOptions = this.options.animation; + if (this.isEnabledTime()) { + if (time === undefined) { + clear(context); + return this; + } + if (this.context === '2d') { + context.save(); + context.globalCompositeOperation = 'destination-out'; + context.fillStyle = 'rgba(0, 0, 0, .1)'; + context.fillRect(0, 0, context.canvas.width, context.canvas.height); + context.restore(); + } + } else { + clear(context); + } + + if (this.context === '2d') { + for (var key in this.options) { + context[key] = this.options[key]; + } + } else { + context.clear(context.COLOR_BUFFER_BIT); + } + var dataGetOptions = { + transferCoordinate: function transferCoordinate(coordinate) { + var _pixel = map.lngLatToContainer(new AMap.LngLat(coordinate[0], coordinate[1])); + return [_pixel['x'], _pixel['y']]; + } + }; + + if (time !== undefined) { + dataGetOptions.filter = function (item) { + var trails = animationOptions.trails || 10; + if (time && item.time > time - trails && item.time < time) { + return true; + } else { + return false; + } + }; + } + + var data = this.dataSet.get(dataGetOptions); + this.processData(data); + + if (this.options.unit === 'm') { + if (this.options.size) { + this.options._size = this.options.size / zoomUnit; + } + if (this.options.width) { + this.options._width = this.options.width / zoomUnit; + } + if (this.options.height) { + this.options._height = this.options.height / zoomUnit; + } + } else { + this.options._size = this.options.size; + this.options._height = this.options.height; + this.options._width = this.options.width; + } + + this.drawContext(context, new DataSet(data), this.options, { x: 0, y: 0 }); + this.options.updateCallback && this.options.updateCallback(time); + return this; + } + + /** + * get canvas layer + */ + + }, { + key: "getCanvasLayer", + value: function getCanvasLayer() { + if (!this.canvasLayer.canvas && !this.layer_) { + var canvas = this.canvasFunction(); + var bounds = this.map.getBounds(); + this.layer_ = new AMap.CanvasLayer({ + canvas: canvas, + bounds: this.options.bounds || bounds, + zooms: this.options.zooms || [0, 22] + }); + this.layer_.setMap(this.map); + this.map.on('mapmove', this.canvasFunction, this); + this.map.on('zoomchange', this.canvasFunction, this); + } + } + + /** + * canvas constructor + * @returns {*} + */ + + }, { + key: "canvasFunction", + value: function canvasFunction() { + var _ref = [this.map.getSize().width, this.map.getSize().height], + width = _ref[0], + height = _ref[1]; + + if (!this.canvasLayer.canvas) { + this.canvasLayer.canvas = createCanvas(width, height); + } else { + this.canvasLayer.canvas.width = width; + this.canvasLayer.canvas.height = height; + var bounds = this.map.getBounds(); + if (this.layer_) { + this.layer_.setBounds(this.options.bounds || bounds); + } + } + this.render(this.canvasLayer.canvas); + return this.canvasLayer.canvas; + } + + /** + * remove layer + */ + + }, { + key: "removeLayer", + value: function removeLayer() { + if (!this.map) return; + this.unEvents(); + this.map.removeLayer(this.layer_); + delete this.map; + delete this.layer_; + delete this.canvasLayer.canvas; + } + }, { + key: "getContext", + value: function getContext() { + return this.canvasLayer.canvas.getContext(this.context); + } + + /** + * handle click event + * @param event + */ + + }, { + key: "clickEvent", + value: function clickEvent(event) { + var pixel = event.pixel; + get(Layer.prototype.__proto__ || Object.getPrototypeOf(Layer.prototype), "clickEvent", this).call(this, pixel, event); + } + + /** + * handle mousemove/pointermove event + * @param event + */ + + }, { + key: "mousemoveEvent", + value: function mousemoveEvent(event) { + var pixel = event.pixel; + get(Layer.prototype.__proto__ || Object.getPrototypeOf(Layer.prototype), "mousemoveEvent", this).call(this, pixel, event); + } + + /** + * add animator event + */ + + }, { + key: "addAnimatorEvent", + value: function addAnimatorEvent() { + this.map.on('movestart', this.animatorMovestartEvent, this); + this.map.on('moveend', this.animatorMoveendEvent, this); + } + + /** + * bind event + */ + + }, { + key: "onEvents", + value: function onEvents() { + var map = this.map; + this.unEvents(); + if (this.options.methods) { + if (this.options.methods.click) { + map.on('click', this.clickEvent, this); + } + if (this.options.methods.mousemove) { + map.on('mousemove', this.mousemoveEvent, this); + } + } + } + + /** + * unbind events + */ + + }, { + key: "unEvents", + value: function unEvents() { + var map = this.map; + if (this.options.methods) { + if (this.options.methods.click) { + map.off('click', this.clickEvent, this); + } + if (this.options.methods.mousemove) { + map.off('mousemove', this.mousemoveEvent, this); + } + } + } + }]); + return Layer; +}(BaseLayer); + +/** + * MapV for openlayers (https://openlayers.org) + * @author sakitam-fdd - https://github.com/sakitam-fdd + */ + +/** + * create canvas + * @param width + * @param height + * @returns {HTMLCanvasElement} + */ +var createCanvas$1 = function createCanvas(width, height) { + if (typeof document !== 'undefined') { + var canvas = document.createElement('canvas'); + canvas.width = width; + canvas.height = height; + return canvas; + } else { + // create a new canvas instance in node.js + // the canvas class needs to have a default constructor without any parameter + } +}; + +var Layer$8 = function (_BaseLayer) { + inherits(Layer, _BaseLayer); + + function Layer() { + var map = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; + var dataSet = arguments[1]; + var options = arguments[2]; + classCallCheck(this, Layer); + + var _this = possibleConstructorReturn(this, (Layer.__proto__ || Object.getPrototypeOf(Layer)).call(this, map, dataSet, options)); + + _this.options = options; + + /** + * internal + * @type {{canvas: null, devicePixelRatio: number}} + */ + _this.canvasLayer = { + canvas: null, + devicePixelRatio: window.devicePixelRatio + + /** + * cavnas layer + * @type {null} + * @private + */ + };_this.layer_ = null; + + /** + * previous cursor + * @type {undefined} + * @private + */ + _this.previousCursor_ = undefined; + + _this.init(map, options); + _this.argCheck(options); + return _this; + } + + /** + * init mapv layer + * @param map + * @param options + */ + + + createClass(Layer, [{ + key: "init", + value: function init(map, options) { + if (map && map instanceof ol.Map) { + this.$Map = map; + this.context = this.options.context || '2d'; + this.getCanvasLayer(); + this.initDataRange(options); + this.initAnimator(); + this.onEvents(); + } else { + throw new Error('not map object'); + } + } + + /** + * update layer + * @param time + * @private + */ + + }, { + key: "_canvasUpdate", + value: function _canvasUpdate(time) { + this.render(this.canvasLayer.canvas, time); + } + + /** + * render layer + * @param canvas + * @param time + * @returns {Layer} + */ + + }, { + key: "render", + value: function render(canvas, time) { + var map = this.$Map; + var context = canvas.getContext(this.context); + var animationOptions = this.options.animation; + var _projection = this.options.hasOwnProperty('projection') ? this.options.projection : 'EPSG:4326'; + if (this.isEnabledTime()) { + if (time === undefined) { + clear(context); + return this; + } + if (this.context === '2d') { + context.save(); + context.globalCompositeOperation = 'destination-out'; + context.fillStyle = 'rgba(0, 0, 0, .1)'; + context.fillRect(0, 0, context.canvas.width, context.canvas.height); + context.restore(); } - }, { - key: "unbindEvent", - value: function unbindEvent(e) { - var map = this.map; + } else { + clear(context); + } - if (this.options.methods) { - if (this.options.methods.click) { - map.removeListener('click', this.clickEvent); - } - if (this.options.methods.mousemove) { - map.removeListener('mousemove', this.mousemoveEvent); - } - } + if (this.context === '2d') { + for (var key in this.options) { + context[key] = this.options[key]; } - }, { - key: "getContext", - value: function getContext() { - return this.canvasLayer.canvas.getContext(this.context); + } else { + context.clear(context.COLOR_BUFFER_BIT); + } + var dataGetOptions = { + transferCoordinate: function transferCoordinate(coordinate) { + return map.getPixelFromCoordinate(ol.proj.transform(coordinate, _projection, 'EPSG:4326')); } - }, { - key: "_canvasUpdate", - value: function _canvasUpdate(time) { - if (!this.canvasLayer) { - return; - } + }; - var self = this; + if (time !== undefined) { + dataGetOptions.filter = function (item) { + var trails = animationOptions.trails || 10; + if (time && item.time > time - trails && item.time < time) { + return true; + } else { + return false; + } + }; + } - var animationOptions = self.options.animation; + var data = this.dataSet.get(dataGetOptions); + this.processData(data); - var context = this.getContext(); + if (this.options.unit === 'm') { + if (this.options.size) { + this.options._size = this.options.size / zoomUnit; + } + if (this.options.width) { + this.options._width = this.options.width / zoomUnit; + } + if (this.options.height) { + this.options._height = this.options.height / zoomUnit; + } + } else { + this.options._size = this.options.size; + this.options._height = this.options.height; + this.options._width = this.options.width; + } - if (self.isEnabledTime()) { - if (time === undefined) { - clear(context); - return; - } - if (this.context == '2d') { - context.save(); - context.globalCompositeOperation = 'destination-out'; - context.fillStyle = 'rgba(0, 0, 0, .1)'; - context.fillRect(0, 0, context.canvas.width, context.canvas.height); - context.restore(); - } - } else { - clear(context); - } + this.drawContext(context, new DataSet(data), this.options, { x: 0, y: 0 }); + this.options.updateCallback && this.options.updateCallback(time); + return this; + } - if (this.context == '2d') { - for (var key in self.options) { - context[key] = self.options[key]; - } - } else { - context.clear(context.COLOR_BUFFER_BIT); - } + /** + * get canvas layer + */ - if (self.options.minZoom && map.getZoom() < self.options.minZoom || self.options.maxZoom && map.getZoom() > self.options.maxZoom) { - return; - } + }, { + key: "getCanvasLayer", + value: function getCanvasLayer() { + if (!this.canvasLayer.canvas && !this.layer_) { + var extent = this.getMapExtent(); + this.layer_ = new ol.layer.Image({ + layerName: this.options.layerName, + minResolution: this.options.minResolution, + maxResolution: this.options.maxResolution, + zIndex: this.options.zIndex, + extent: extent, + source: new ol.source.ImageCanvas({ + canvasFunction: this.canvasFunction.bind(this), + projection: this.options.hasOwnProperty('projection') ? this.options.projection : 'EPSG:4326', + ratio: this.options.hasOwnProperty('ratio') ? this.options.ratio : 1 + }) + }); + this.$Map.addLayer(this.layer_); + this.$Map.un('precompose', this.reRender, this); + this.$Map.on('precompose', this.reRender, this); + } + } - var scale = 1; - if (this.context != '2d') { - scale = this.canvasLayer.devicePixelRatio; - } + /** + * re render + */ - var map = this.map; - var mapProjection = map.getProjection(); - var scale = Math.pow(2, map.zoom) * resolutionScale; - var offset = mapProjection.fromLatLngToPoint(this.canvasLayer.getTopLeft()); - var dataGetOptions = { - //fromColumn: self.options.coordType == 'bd09mc' ? 'coordinates' : 'coordinates_mercator', - transferCoordinate: function transferCoordinate(coordinate) { - var latLng = new google.maps.LatLng(coordinate[1], coordinate[0]); - var worldPoint = mapProjection.fromLatLngToPoint(latLng); - var pixel = { - x: (worldPoint.x - offset.x) * scale, - y: (worldPoint.y - offset.y) * scale - }; - return [pixel.x, pixel.y]; - } - }; + }, { + key: "reRender", + value: function reRender() { + if (!this.layer_) return; + var extent = this.getMapExtent(); + this.layer_.setExtent(extent); + } - if (time !== undefined) { - dataGetOptions.filter = function (item) { - var trails = animationOptions.trails || 10; - if (time && item.time > time - trails && item.time < time) { - return true; - } else { - return false; - } - }; - } + /** + * canvas constructor + * @param extent + * @param resolution + * @param pixelRatio + * @param size + * @param projection + * @returns {*} + */ - // get data from data set - var data = self.dataSet.get(dataGetOptions); + }, { + key: "canvasFunction", + value: function canvasFunction(extent, resolution, pixelRatio, size, projection) { + if (!this.canvasLayer.canvas) { + this.canvasLayer.canvas = createCanvas$1(size[0], size[1]); + } else { + this.canvasLayer.canvas.width = size[0]; + this.canvasLayer.canvas.height = size[1]; + } + this.render(this.canvasLayer.canvas); + return this.canvasLayer.canvas; + } - this.processData(data); + /** + * get map current extent + * @returns {Array} + */ - var latLng = new google.maps.LatLng(0, 0); - var worldPoint = mapProjection.fromLatLngToPoint(latLng); - var pixel = { - x: (worldPoint.x - offset.x) * scale, - y: (worldPoint.y - offset.y) * scale - }; + }, { + key: "getMapExtent", + value: function getMapExtent() { + var size = this.$Map.getSize(); + return this.$Map.getView().calculateExtent(size); + } - if (self.options.unit == 'm' && self.options.size) { - self.options._size = self.options.size / zoomUnit; - } else { - self.options._size = self.options.size; - } + /** + * add layer to map + * @param map + */ - this.drawContext(context, new DataSet(data), self.options, pixel); + }, { + key: "addTo", + value: function addTo(map) { + this.init(map, this.options); + } - //console.timeEnd('draw'); + /** + * remove layer + */ - //console.timeEnd('update') - self.options.updateCallback && self.options.updateCallback(time); - } - }, { - key: "init", - value: function init(options) { + }, { + key: "removeLayer", + value: function removeLayer() { + if (!this.$Map) return; + this.unEvents(); + this.$Map.un('precompose', this.reRender, this); + this.$Map.removeLayer(this.layer_); + delete this.$Map; + delete this.layer_; + delete this.canvasLayer.canvas; + } + }, { + key: "getContext", + value: function getContext() { + return this.canvasLayer.canvas.getContext(this.context); + } - var self = this; + /** + * handle click event + * @param event + */ - self.options = options; + }, { + key: "clickEvent", + value: function clickEvent(event) { + var pixel = event.pixel; + get(Layer.prototype.__proto__ || Object.getPrototypeOf(Layer.prototype), "clickEvent", this).call(this, { + x: pixel[0], + y: pixel[1] + }, event); + } - this.initDataRange(options); + /** + * handle mousemove/pointermove event + * @param event + */ - this.context = self.options.context || '2d'; + }, { + key: "mousemoveEvent", + value: function mousemoveEvent(event) { + var pixel = event.pixel; + get(Layer.prototype.__proto__ || Object.getPrototypeOf(Layer.prototype), "mousemoveEvent", this).call(this, { + x: pixel[0], + y: pixel[1] + }, event); + } - if (self.options.zIndex) { - this.canvasLayer && this.canvasLayer.setZIndex(self.options.zIndex); - } + /** + * add animator event + */ - this.initAnimator(); + }, { + key: "addAnimatorEvent", + value: function addAnimatorEvent() { + this.$Map.on('movestart', this.animatorMovestartEvent, this); + this.$Map.on('moveend', this.animatorMoveendEvent, this); + } + + /** + * bind event + */ + + }, { + key: "onEvents", + value: function onEvents() { + var map = this.$Map; + this.unEvents(); + if (this.options.methods) { + if (this.options.methods.click) { + map.on('click', this.clickEvent, this); } - }, { - key: "addAnimatorEvent", - value: function addAnimatorEvent() { - this.map.addListener('movestart', this.animatorMovestartEvent.bind(this)); - this.map.addListener('moveend', this.animatorMoveendEvent.bind(this)); + if (this.options.methods.mousemove) { + map.on('pointermove', this.mousemoveEvent, this); } - }, { - key: "show", - value: function show() { - this.map.addOverlay(this.canvasLayer); + } + } + + /** + * unbind events + */ + + }, { + key: "unEvents", + value: function unEvents() { + var map = this.$Map; + if (this.options.methods) { + if (this.options.methods.click) { + map.un('click', this.clickEvent, this); } - }, { - key: "hide", - value: function hide() { - this.map.removeOverlay(this.canvasLayer); + if (this.options.methods.pointermove) { + map.un('pointermove', this.mousemoveEvent, this); } - }, { - key: "draw", - value: function draw() { - self.canvasLayer.draw(); + } + } + + /** + * set map cursor + * @param cursor + * @param feature + */ + + }, { + key: "setDefaultCursor", + value: function setDefaultCursor(cursor, feature) { + if (!this.$Map) return; + var element = this.$Map.getTargetElement(); + if (feature) { + if (element.style.cursor !== cursor) { + this.previousCursor_ = element.style.cursor; + element.style.cursor = cursor; } - }]); - return Layer; + } else if (this.previousCursor_ !== undefined) { + element.style.cursor = this.previousCursor_; + this.previousCursor_ = undefined; + } + } + }]); + return Layer; }(BaseLayer); /** @@ -7693,16 +8905,18 @@ var geojson = { var data = []; var features = geoJson.features; - for (var i = 0; i < features.length; i++) { - var feature = features[i]; - var geometry = feature.geometry; - var properties = feature.properties; - var item = {}; - for (var key in properties) { - item[key] = properties[key]; + if (features) { + for (var i = 0; i < features.length; i++) { + var feature = features[i]; + var geometry = feature.geometry; + var properties = feature.properties; + var item = {}; + for (var key in properties) { + item[key] = properties[key]; + } + item.geometry = geometry; + data.push(item); } - item.geometry = geometry; - data.push(item); } return new DataSet(data); } @@ -7828,6 +9042,9 @@ exports.baiduMapAnimationLayer = AnimationLayer; exports.baiduMapLayer = Layer; exports.googleMapCanvasLayer = CanvasLayer$2; exports.googleMapLayer = Layer$2; +exports.MaptalksLayer = Layer$5; +exports.AMapLayer = Layer$6; +exports.OpenlayersLayer = Layer$8; exports.DataSet = DataSet; exports.geojson = geojson; exports.csv = csv; @@ -13510,7 +14727,10 @@ var App = function (_Component) { null, child ), this.contentDom); - this.marker = new _CustomOverlay2.default(position, this.contentDom, this.props.offset); + this.marker = new _CustomOverlay2.default(position, this.contentDom, { + zIndex: this.props.zIndex, + offset: this.props.offset + }); map.addOverlay(this.marker); } else { var options = this.getOptions(this.options); @@ -18529,27 +19749,6 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { */ componentWillUnmount: 'DEFINE_MANY', - /** - * Replacement for (deprecated) `componentWillMount`. - * - * @optional - */ - UNSAFE_componentWillMount: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillReceiveProps`. - * - * @optional - */ - UNSAFE_componentWillReceiveProps: 'DEFINE_MANY', - - /** - * Replacement for (deprecated) `componentWillUpdate`. - * - * @optional - */ - UNSAFE_componentWillUpdate: 'DEFINE_MANY', - // ==== Advanced methods ==== /** @@ -18565,23 +19764,6 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { updateComponent: 'OVERRIDE_BASE' }; - /** - * Similar to ReactClassInterface but for static methods. - */ - var ReactClassStaticInterface = { - /** - * This method is invoked after a component is instantiated and when it - * receives new props. Return an object to update state in response to - * prop changes. Return null to indicate no change to state. - * - * If an object is returned, its keys will be merged into the existing state. - * - * @return {object || null} - * @optional - */ - getDerivedStateFromProps: 'DEFINE_MANY_MERGED' - }; - /** * Mapping from class specification keys to special processing functions. * @@ -18816,7 +19998,6 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { if (!statics) { return; } - for (var name in statics) { var property = statics[name]; if (!statics.hasOwnProperty(name)) { @@ -18833,25 +20014,14 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { name ); - var isAlreadyDefined = name in Constructor; - if (isAlreadyDefined) { - var specPolicy = ReactClassStaticInterface.hasOwnProperty(name) - ? ReactClassStaticInterface[name] - : null; - - _invariant( - specPolicy === 'DEFINE_MANY_MERGED', - 'ReactClass: You are attempting to define ' + - '`%s` on your component more than once. This conflict may be ' + - 'due to a mixin.', - name - ); - - Constructor[name] = createMergedResultFunction(Constructor[name], property); - - return; - } - + var isInherited = name in Constructor; + _invariant( + !isInherited, + 'ReactClass: You are attempting to define ' + + '`%s` on your component more than once. This conflict may be ' + + 'due to a mixin.', + name + ); Constructor[name] = property; } } @@ -19161,12 +20331,6 @@ function factory(ReactComponent, isValidElement, ReactNoopUpdateQueue) { 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component' ); - warning( - !Constructor.prototype.UNSAFE_componentWillRecieveProps, - '%s has a method called UNSAFE_componentWillRecieveProps(). ' + - 'Did you mean UNSAFE_componentWillReceiveProps()?', - spec.displayName || 'A component' - ); } // Reduce time spent doing lookups by setting these on the prototype. @@ -29870,10 +31034,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); // 自定义覆盖物 -function CustomOverlay(point, content, offset) { +function CustomOverlay(point, content, options) { + this.options = options || {}; this._point = point; this.content = content; - this.offset = offset || new BMap.Size(0, 0); } CustomOverlay.prototype = new BMap.Overlay(); @@ -29883,7 +31047,8 @@ CustomOverlay.prototype.initialize = function (map) { var div = this._div = document.createElement("div"); div.setAttribute('tag', 'customoverlay'); div.style.position = "absolute"; - div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat); + var zIndex = this.options.zIndex || BMap.Overlay.getZIndex(this._point.lat); + div.style.zIndex = zIndex; div.addEventListener('touchstart', function (e) { e.stopPropagation(); console.log('touchstart'); @@ -29910,8 +31075,9 @@ CustomOverlay.prototype.initialize = function (map) { CustomOverlay.prototype.draw = function () { var map = this._map; var pixel = map.pointToOverlayPixel(this._point); - this._div.style.left = pixel.x + this.offset.width + "px"; - this._div.style.top = pixel.y + this.offset.height + "px"; + var offset = this.options.offset || new BMap.Size(0, 0); + this._div.style.left = pixel.x + offset.width + "px"; + this._div.style.top = pixel.y + offset.height + "px"; }; exports.default = CustomOverlay; diff --git a/package.json b/package.json index 8b80f13..e5fe055 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-bmap", - "version": "1.0.91", + "version": "1.0.93", "description": "react-bmap", "main": "lib/index.js", "contributors": [ diff --git a/src/components/marker.js b/src/components/marker.js index 0014dce..1bc9ea9 100644 --- a/src/components/marker.js +++ b/src/components/marker.js @@ -164,7 +164,10 @@ export default class App extends Component { this.contentDom = document.createElement('div'); const child = this.props.children; render(
{child}
, this.contentDom) - this.marker = new CustomOverlay(position, this.contentDom, this.props.offset); + this.marker = new CustomOverlay(position, this.contentDom, { + zIndex: this.props.zIndex, + offset: this.props.offset + }); map.addOverlay(this.marker); } else { var options = this.getOptions(this.options); diff --git a/src/components/marker.md b/src/components/marker.md index a776791..9e10d09 100644 --- a/src/components/marker.md +++ b/src/components/marker.md @@ -3,6 +3,7 @@ ## 可配置属性 - position={{lng: 123, lat: 23}} +- zIndex="10" 目前只对自定义覆盖物生效 - offset={new BMap.Size(10, 10)} - icon={String|BMap.Icon} 可配置一些我们事先配置好的icon样式,'simple_red','simple_blue','loc_red','loc_blue','start','end', 'number1', 'number2', ``` 'number10',或者可以自定义icon - enableClicking={false} diff --git a/src/overlay/CustomOverlay.js b/src/overlay/CustomOverlay.js index 5515720..68baba2 100644 --- a/src/overlay/CustomOverlay.js +++ b/src/overlay/CustomOverlay.js @@ -1,8 +1,8 @@ // 自定义覆盖物 -function CustomOverlay(point, content, offset) { +function CustomOverlay(point, content, options) { + this.options = options || {}; this._point = point; this.content = content; - this.offset = offset || new BMap.Size(0, 0); } CustomOverlay.prototype = new BMap.Overlay(); @@ -12,7 +12,8 @@ CustomOverlay.prototype.initialize = function(map){ var div = this._div = document.createElement("div"); div.setAttribute('tag', 'customoverlay'); div.style.position = "absolute"; - div.style.zIndex = BMap.Overlay.getZIndex(this._point.lat); + var zIndex = this.options.zIndex || BMap.Overlay.getZIndex(this._point.lat); + div.style.zIndex = zIndex; div.addEventListener('touchstart', function (e) { e.stopPropagation(); console.log('touchstart'); @@ -39,8 +40,9 @@ CustomOverlay.prototype.initialize = function(map){ CustomOverlay.prototype.draw = function(){ var map = this._map; var pixel = map.pointToOverlayPixel(this._point); - this._div.style.left = pixel.x + this.offset.width + "px"; - this._div.style.top = pixel.y + this.offset.height + "px"; + var offset = this.options.offset || new BMap.Size(0, 0); + this._div.style.left = pixel.x + offset.width + "px"; + this._div.style.top = pixel.y + offset.height + "px"; } export default CustomOverlay;