9 lines
75 KiB
Vue
9 lines
75 KiB
Vue
|
/*!
|
||
|
* Copyright (c) 2016, Baidu, Inc. All rights reserved.
|
||
|
* mapv.(http://mapv.baidu.com)
|
||
|
* github: https://github.com/huiyan-fe/mapv
|
||
|
* license: BSD 3-clause "New" or "Revised"
|
||
|
*/
|
||
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.mapv=t.mapv||{})}(this,function(t){"use strict";function e(){this._subscribers={}}function n(t,n){e.bind(this)(),this._options=n||{},this._data=[],t&&this.add(t)}function i(t,e){var n;if("undefined"==typeof document);else{var n=document.createElement("canvas");t&&(n.width=t),e&&(n.height=e)}return n}function o(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function r(t){var e=t/2,n=t+e,o=1e4,r=new i(2*n,2*n),a=r.getContext("2d");return a.shadowBlur=e,a.shadowColor="black",a.shadowOffsetX=a.shadowOffsetY=o,a.beginPath(),a.arc(n-o,n-o,t,0,2*Math.PI,!0),a.closePath(),a.fill(),r}function a(t,e,n){for(var i,o=n.maxOpacity||.8,r=3,a=t.length;r<a;r+=4)i=4*t[r],t[r]/256>o&&(t[r]=256*o),t[r-3]=e[i],t[r-2]=e[i+1],t[r-1]=e[i+2]}function s(t,e,n){var i=n.max||100,a=n.min||0,s=n._size;void 0==s&&(s=n.size,void 0==s&&(s=13));var l=new o({gradient:n.gradient,max:i,min:a}),u=r(s),h=u.width/2,g=u.height/2,c=e,p={};c.forEach(function(t,e){var n=void 0===t.count?1:t.count,o=Math.min(1,n/i).toFixed(2);p[o]=p[o]||[],p[o].push(t)});for(var f in p)if(!isNaN(f)){var v=p[f];t.beginPath(),n.withoutAlpha||(t.globalAlpha=f),t.strokeStyle=l.getColor(f*i),v.forEach(function(e,o){if(e.geometry){var r=e.geometry._coordinates||e.geometry.coordinates,a=e.geometry.type;if("Point"===a){var s=void 0===e.count?1:e.count;t.globalAlpha=s/i,t.drawImage(u,r[0]-h,r[1]-g)}else if("LineString"===a){var s=void 0===e.count?1:e.count;t.globalAlpha=s/i,t.beginPath(),ht.draw(t,e,n),t.stroke()}}})}}function l(t,e,r){var l=r.strength||.3;t.strokeStyle="rgba(0,0,0,"+l+")";var u=new i(t.canvas.width,t.canvas.height),h=u.getContext("2d");h.scale(pt,pt),r=r||{};var g=e instanceof n?e.get():e;t.save();var c=new o({gradient:r.gradient});if(s(h,g,r),!r.absolute){var p=h.getImageData(0,0,t.canvas.width,t.canvas.height);a(p.data,c.getImageData(),r),t.putImageData(p,0,0),t.restore()}c=null,u=null}function u(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 h(t,e,n){var i=t.createShader(n);return t.shaderSource(i,e),t.compileShader(i),i}function g(t,e,n){var i=h(t,e,t.VERTEX_SHADER),o=h(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 c(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 p(t,e,n){if(e){var i=g(t,yt,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=c(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 h=0,p=e.length;h<p;h++){for(var f=e[h].geometry._coordinates,v=[],d=0;d<f.length;d++){var y=f[d],m=(y[0]-o)/o,x=(r-y[1])/r;v.push(m,x)}var w=new Float32Array(v);t.bufferData(t.ARRAY_BUFFER,w,t.STATIC_DRAW),t.drawArrays(t.LINE_STRIP,0,f.length)}}}function f(t,e,n){if(e){var i=g(t,wt,_t),o=t.getAttribLocation(i,"a_Position"),r=t.getAttribLocation(i,"a_PointSize"),a=t.getUniformLocation(i,"u_FragColor");t.clear(t.COLOR_BUFFER_BIT);for(var s=t.canvas.width/2,l=t.canvas.height/2,u=[],h=0,p=0;p<e.length;p++){var f=e[p].geometry._coordinates,v=(f[0]-s)/s,d=(l-f[1])/l;v<-1||v>1||d<-1||d>1||(u.push(v,d),h++)}var y=new Float32Array(u),m=h,x=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,x),t.bufferData(t.ARRAY_BUFFER,y,t.STATIC_DRAW),t.vertexAttribPointer(o,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(o),t.vertexAttrib1f(r,n._size);var w=c(n.fillStyle||"red");t.uniform4f(a,w[0]/
|
||
|
},{n:"白山",g:"126.435798,41.945859|13"},{n:"吉林市",g:"126.564544,43.871988|12"},{n:"辽源",g:"125.133686,42.923303|13"},{n:"四平",g:"124.391382,43.175525|12"},{n:"松原",g:"124.832995,45.136049|13"},{n:"通化",g:"125.94265,41.736397|13"},{n:"延边",g:"129.485902,42.896414|13"}]},{n:"辽宁",g:"122.753592,41.6216|8",cities:[{n:"沈阳",g:"123.432791,41.808645|12"},{n:"鞍山",g:"123.007763,41.118744|13"},{n:"本溪",g:"123.778062,41.325838|12"},{n:"朝阳",g:"120.446163,41.571828|13"},{n:"大连",g:"121.593478,38.94871|12"},{n:"丹东",g:"124.338543,40.129023|12"},{n:"抚顺",g:"123.92982,41.877304|12"},{n:"阜新",g:"121.660822,42.01925|14"},{n:"葫芦岛",g:"120.860758,40.74303|13"},{n:"锦州",g:"121.147749,41.130879|13"},{n:"辽阳",g:"123.172451,41.273339|14"},{n:"盘锦",g:"122.073228,41.141248|13"},{n:"铁岭",g:"123.85485,42.299757|13"},{n:"营口",g:"122.233391,40.668651|13"}]},{n:"内蒙古",g:"114.415868,43.468238|5",cities:[{n:"呼和浩特",g:"111.660351,40.828319|12"},{n:"阿拉善盟",g:"105.695683,38.843075|14"},{n:"包头",g:"109.846239,40.647119|12"},{n:"巴彦淖尔",g:"107.423807,40.76918|12"},{n:"赤峰",g:"118.930761,42.297112|12"},{n:"鄂尔多斯",g:"109.993706,39.81649|12"},{n:"呼伦贝尔",g:"119.760822,49.201636|12"},{n:"通辽",g:"122.260363,43.633756|12"},{n:"乌海",g:"106.831999,39.683177|13"},{n:"乌兰察布",g:"113.112846,41.022363|12"},{n:"锡林郭勒盟",g:"116.02734,43.939705|11"},{n:"兴安盟",g:"122.048167,46.083757|11"}]},{n:"宁夏",g:"106.155481,37.321323|8",cities:[{n:"银川",g:"106.206479,38.502621|12"},{n:"固原",g:"106.285268,36.021523|13"},{n:"石嘴山",g:"106.379337,39.020223|13"},{n:"吴忠",g:"106.208254,37.993561|14"},{n:"中卫",g:"105.196754,37.521124|14"}]},{n:"青海",g:"96.202544,35.499761|7",cities:[{n:"西宁",g:"101.767921,36.640739|12"},{n:"果洛州",g:"100.223723,34.480485|11"},{n:"海东地区",g:"102.085207,36.51761|11"},{n:"海北州",g:"100.879802,36.960654|11"},{n:"海南州",g:"100.624066,36.284364|11"},{n:"海西州",g:"97.342625,37.373799|11"},{n:"黄南州",g:"102.0076,35.522852|11"},{n:"玉树州",g:"97.013316,33.00624|14"}]},{n:"山东",g:"118.527663,36.09929|8",cities:[{n:"济南",g:"117.024967,36.682785|12"},{n:"滨州",g:"117.968292,37.405314|12"},{n:"东营",g:"118.583926,37.487121|12"},{n:"德州",g:"116.328161,37.460826|12"},{n:"菏泽",g:"115.46336,35.26244|13"},{n:"济宁",g:"116.600798,35.402122|13"},{n:"莱芜",g:"117.684667,36.233654|13"},{n:"聊城",g:"115.986869,36.455829|12"},{n:"临沂",g:"118.340768,35.072409|12"},{n:"青岛",g:"120.384428,36.105215|12"},{n:"日照",g:"119.50718,35.420225|12"},{n:"泰安",g:"117.089415,36.188078|13"},{n:"威海",g:"122.093958,37.528787|13"},{n:"潍坊",g:"119.142634,36.716115|12"},{n:"烟台",g:"121.309555,37.536562|12"},{n:"枣庄",g:"117.279305,34.807883|13"},{n:"淄博",g:"118.059134,36.804685|12"}]},{n:"山西",g:"112.515496,37.866566|7",cities:[{n:"太原",g:"112.550864,37.890277|12"},{n:"长治",g:"113.120292,36.201664|12"},{n:"大同",g:"113.290509,40.113744|12"},{n:"晋城",g:"112.867333,35.499834|13"},{n:"晋中",g:"112.738514,37.693362|13"},{n:"临汾",g:"111.538788,36.099745|13"},{n:"吕梁",g:"111.143157,37.527316|14"},{n:"朔州",g:"112.479928,39.337672|13"},{n:"忻州",g:"112.727939,38.461031|12"},{n:"阳泉",g:"113.569238,37.869529|13"},{n:"运城",g:"111.006854,35.038859|13"}]},{n:"陕西",g:"109.503789,35.860026|7",cities:[{n:"西安",g:"108.953098,34.2778|12"},{n:"安康",g:"109.038045,32.70437|13"},{n:"宝鸡",g:"107.170645,34.364081|12"},{n:"汉中",g:"107.045478,33.081569|13"},{n:"商洛",g:"109.934208,33.873907|13"},{n:"铜川",g:"108.968067,34.908368|13"},{n:"渭南",g:"109.483933,34.502358|13"},{n:"咸阳",g:"108.707509,34.345373|13"},{n:"延安",g:"109.50051,36.60332|13"},{n:"榆林",g:"109.745926,38.279439|12"}]},{n:"四川",g:"102.89916,30.367481|7",cities:[{n:"成都",g:"104.067923,30.679943|12"},{n:"阿坝州",g:"102.228565,31.905763|15"},{n:"巴中",g:"106.757916,31.869189|14"},{n:"达州",g:"107.494973,31.214199|14"},{n:"德阳",g:"104.402398,31.13114
|
||
|
if(e.isEnabledTime()){if(void 0===t)return void it(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 it(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.minZoom||e.options.maxZoom&&i.getZoom()>e.options.maxZoom)){var h=1;"2d"!=this.context&&(h=this.canvasLayer.devicePixelRatio);var g={fromColumn:"bd09mc"==e.options.coordType?"coordinates":"coordinates_mercator",transferCoordinate:function(t){var e=(t[0]-s.x)/o*h,n=(s.y-t[1])/o*h;return[e,n]}};void 0!==t&&(g.filter=function(e){var i=n.trails||10;return!!(t&&e.time>t-i&&e.time<t)});var c=e.dataSet.get(g);this.processData(c);var p=i.pointToPixel(new BMap.Point(0,0));"m"==e.options.unit?(e.options.size&&(e.options._size=e.options.size/o),e.options.width&&(e.options._width=e.options.width/o),e.options.height&&(e.options._height=e.options.height/o)):(e.options._size=e.options.size,e.options._height=e.options.height,e.options._width=e.options.width),this.drawContext(l,c,e.options,p),e.options.updateCallback&&e.options.updateCallback(t)}}}},{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:"addAnimatorEvent",value:function(){this.map.addEventListener("movestart",this.animatorMovestartEvent.bind(this)),this.map.addEventListener("moveend",this.animatorMoveendEvent.bind(this))}},{key:"show",value:function(){this.map.addOverlay(this.canvasLayer)}},{key:"hide",value:function(){this.map.removeOverlay(this.canvasLayer)}},{key:"draw",value:function(){this.canvasLayer.draw()}}]),e}(Ot),Ut="undefined"==typeof window?{}:window;Ut.google&&Ut.google.maps&&(et.prototype=new google.maps.OverlayView,et.DEFAULT_PANE_NAME_="overlayLayer",et.CSS_TRANSFORM_=function(){for(var t=document.createElement("div"),e=["transform","WebkitTransform","MozTransform","OTransform","msTransform"],n=0;n<e.length;n++){var i=e[n];if(void 0!==t.style[i])return i}return e[0]}(),et.prototype.requestAnimFrame_=Ut.requestAnimationFrame||Ut.webkitRequestAnimationFrame||Ut.mozRequestAnimationFrame||Ut.oRequestAnimationFrame||Ut.msRequestAnimationFrame||function(t){return Ut.setTimeout(t,1e3/60)},et.prototype.cancelAnimFrame_=Ut.cancelAnimationFrame||Ut.webkitCancelAnimationFrame||Ut.mozCancelAnimationFrame||Ut.oCancelAnimationFrame||Ut.msCancelAnimationFrame||function(t){},et.prototype.setOptions=function(t){void 0!==t.animate&&this.setAnimate(t.animate),void 0!==t.paneName&&this.setPaneName(t.paneName),void 0!==t.updateHandler&&this.setUpdateHandler(t.updateHandler),void 0!==t.resizeHandler&&this.setResizeHandler(t.resizeHandler),void 0!==t.resolutionScale&&this.setResolutionScale(t.resolutionScale),void 0!==t.map&&this.setMap(t.map)},et.prototype.setAnimate=function(t){this.isAnimated_=!!t,this.isAnimated_&&this.scheduleUpdate()},et.prototype.isAnimated=function(){return this.isAnimated_},et.prototype.setPaneName=function(t){this.paneName_=t,this.setPane_()},et.prototype.getPaneName=function(){return this.paneName_},et.prototype.setPane_=function(){if(this.isAdded_){var t=this.getPanes();if(!t[this.paneName_])throw new Error('"'+this.paneName_+'" is not a valid MapPane name.');t[this.paneName_].appendChild(this.canvas)}},et.prototype.setResizeHandler=function(t){this.resizeHandler_=t},et.prototype.setResolutionScale=function(t){"number"==typeof t&&(this.resolutionScale_=t,this.resize_())},et.prototype.setUpdateHandler=function(t){this.updateHandler_=t},et.prototype.onAdd=function(){this.isAdded_||(this.isAdded_=!0,this.setPane_(),this.resizeListener_=google.maps.event.addListener(this.getMap(),"resize",this.resizeFunction_),this.centerListener_=google.maps.event.addListener(this.getMap(),"center_changed",this.repositionFunction_),this
|