New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

yymap-heatmap

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yymap-heatmap - npm Package Compare versions

Comparing version 0.0.4 to 0.0.5

4

dist/yymap-heatmap.min.js
/*!
* yymap-heatmap v0.0.4
* yymap-heatmap v0.0.5
* this is extends yymap(require yy.js)
* build by Iverson.hu, more info concat me:hudy@yeyoo.cn
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("yymap")):"function"==typeof define&&define.amd?define(["exports","yymap"],e):e((t=t||self).yymap=t.YY||{},t.yymap)}(this,function(t,e){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i,s=(function(t){function e(t){if(!(this instanceof e))return new e(t);this._canvas=t="string"==typeof t?document.getElementById(t):t,this._ctx=t.getContext("2d"),this._width=t.width,this._height=t.height,this._max=1,this._data=[]}(t.exports=e).prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,e){e=void 0===e?15:e;var i=this._circle=this._createCanvas(),a=i.getContext("2d"),r=this._r=t+e;return i.width=i.height=2*r,a.shadowOffsetX=a.shadowOffsetY=2*r,a.shadowBlur=e,a.shadowColor="black",a.beginPath(),a.arc(-r,-r,t,0,2*Math.PI,!0),a.closePath(),a.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(t){var e=this._createCanvas(),i=e.getContext("2d"),a=i.createLinearGradient(0,0,0,256);for(var r in e.width=1,e.height=256,t)a.addColorStop(+r,t[r]);return i.fillStyle=a,i.fillRect(0,0,1,256),this._grad=i.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var e=this._ctx;e.clearRect(0,0,this._width,this._height);for(var i,a=0,r=this._data.length;a<r;a++)i=this._data[a],e.globalAlpha=Math.max(i[2]/this._max,void 0===t?.05:t),e.drawImage(this._circle,i[0]-this._r,i[1]-this._r);var n=e.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),e.putImageData(n,0,0),this},_colorize:function(t,e){for(var i,a=0,r=t.length;a<r;a+=4)(i=4*t[a+3])&&(t[a]=e[i],t[a+1]=e[1+i],t[a+2]=e[2+i])},_createCanvas:function(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}}}(i={exports:{}},i.exports),i.exports),a="yymap-heatmap",n="0.0.4",o=function(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),t};function h(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function u(t,e,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,e);if(void 0===a){var r=Object.getPrototypeOf(t);return null===r?void 0:u(r,e,i)}if("value"in a)return a.value;var n=a.get;return void 0!==n?n.call(i):void 0}function c(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 l(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}var P=e.getNamespace().maptalks,d={max:1,gradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},radius:15,blur:15,minOpacity:.05};function f(t){if(Array.isArray(t[0])){var i=[];return t.forEach(function(t){var e=void 0;e=t instanceof P.Coordinate?[t.x,t.y]:t,i.push(e)}),i}var e=void 0;if(t instanceof P.Coordinate)t.x,t.y;else e=t;return e}var p,_,y=(p=P.Layer,c(v,p),o(v,[{key:"getData",value:function(){return this._heats}},{key:"setData",value:function(t){return t=f(t),this._heats=t||[],this.redraw()}},{key:"addData",value:function(t){return t?((t=f(t))[0]&&Array.isArray(t[0])?P.Util.pushIn(this._heats,t):this._heats.push(t),this.redraw()):this}},{key:"onConfig",value:function(t){for(var e in t)if(d[e])return this.redraw();return this}},{key:"setOpacity",value:function(t){return u(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"setOpacity",this).call(this,t),this.redraw(),this}},{key:"redraw",value:function(){var t=this._getRenderer();return t&&(t.clearHeatCache(),t.setToRedraw()),this}},{key:"isEmpty",value:function(){return!this._heats.length}},{key:"clear",value:function(){return this._heats=[],this.redraw(),this.fire("clear"),this}},{key:"toJSON",value:function(t){t=t||{};var e={type:this.getJSONType(),id:this.getId(),options:this.config()},i=this.getData();if(t.clipExtent){var a=new P.Extent(t.clipExtent),r=this._getHeatRadius();r&&(a=a._expand(r));for(var n=[],o=0,s=i.length;o<s;o++)a.contains(new P.Coordinate(i[o][0],i[o][1]))&&n.push(i[o]);e.data=n}else e.data=i;return e}},{key:"_getHeatRadius",value:function(){return this._getRenderer()?this._getRenderer()._heatRadius:null}}],[{key:"fromJSON",value:function(t){return t&&"HeatLayer"===t.type?new v(t.id,t.data,t.options):null}}]),v);function v(t,e,i){r(this,v),Array.isArray(e)||(i=e,e=null);var a=l(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,t,i));return a._heats=e||[],a}function g(){return r(this,g),l(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}y.mergeOptions(d),y.registerJSONType("HeatLayer"),y.registerRenderer("canvas",(_=P.renderer.CanvasRenderer,c(g,_),o(g,[{key:"draw",value:function(){var e=this.getMap(),t=this.layer,i=e.getContainerExtent(),a=this.prepareCanvas(),r=i;if(a){if(!(a=a.convertTo(function(t){return e._pointToContainerPoint(t)})).intersects(i))return void this.completeRender();r=i.intersection(a)}this._heater||(this._heater=s(this.canvas)),this._heater.radius(t.options.radius||this._heater.defaultRadius,t.options.blur),t.options.gradient&&this._heater.gradient(t.options.gradient),this._heater.max(t.options.max),this._heatViews||(this._heatViews=[]);var n=t.getData();if(0!==n.length){var o=this._heatData(n,r);this._heater.data(o).draw(t.options.minOpacity),this.completeRender()}else this.completeRender()}},{key:"drawOnInteracting",value:function(){this.draw()}},{key:"_heatData",value:function(t,e){var i=this.getMap(),a=this.layer,r=i.getProjection(),n=[],o=this._heater._r,s=void 0===a.options.max?1:a.options.max,h=P.Util.isNil(a.options.maxZoom)?i.getMaxZoom():a.options.maxZoom,u=1/Math.pow(2,Math.max(0,Math.min(h-i.getZoom(),12))),c=o/2,l=[],d=i.offsetPlatform(),f=d.x%c,p=d.y%c,_=void 0,y=void 0,v=void 0,g=void 0,m=void 0,w=void 0;e=e.expand(o).convertTo(function(t){return new P.Point(i._containerPointToPrj(t))}),this._heatRadius=o;for(var x=0,O=t.length;x<O;x++)_=t[x],this._heatViews[x]||(this._heatViews[x]=r.project(new P.Coordinate(_[0],_[1]))),y=this._heatViews[x],e.contains(y)&&(y=i._prjToContainerPoint(y),g=Math.floor((y.x-f)/c)+2,m=Math.floor((y.y-p)/c)+2,w=(void 0!==_.alt?_.alt:void 0!==_[2]?+_[2]:1)*u,l[m]=l[m]||[],(v=l[m][g])?(v[0]=(v[0]*v[2]+y.x*w)/(v[2]+w),v[1]=(v[1]*v[2]+y.y*w)/(v[2]+w),v[2]+=w):l[m][g]=[y.x,y.y,w]);for(var b=0,C=l.length;b<C;b++)if(l[b])for(var R=0,k=l[b].length;R<k;R++)(v=l[b][R])&&n.push([Math.round(v[0]),Math.round(v[1]),Math.min(v[2],s)]);return n}},{key:"onZoomEnd",value:function(){delete this._heatViews,u(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"onZoomEnd",this).apply(this,arguments)}},{key:"onResize",value:function(){if(this.canvas){var t=this.getMap().getSize(),e=t.width,i=t.height;this._heater._canvas.width=e,this._heater._canvas.height=i,this._heater.resize()}u(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"onResize",this).apply(this,arguments)}},{key:"onRemove",value:function(){this.clearHeatCache(),delete this._heater}},{key:"clearHeatCache",value:function(){delete this._heatViews}}]),g)),null!=console&&console.log(a+","+n),t.HeatLayer=y,Object.defineProperty(t,"__esModule",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("yymap")):"function"==typeof define&&define.amd?define(["exports","yymap"],e):e((t=t||self).yymap=t.YY||{},t.yymap)}(this,function(t,e){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i,s=(function(t){function e(t){if(!(this instanceof e))return new e(t);this._canvas=t="string"==typeof t?document.getElementById(t):t,this._ctx=t.getContext("2d"),this._width=t.width,this._height=t.height,this._max=1,this._data=[]}(t.exports=e).prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,e){e=void 0===e?15:e;var i=this._circle=this._createCanvas(),a=i.getContext("2d"),r=this._r=t+e;return i.width=i.height=2*r,a.shadowOffsetX=a.shadowOffsetY=2*r,a.shadowBlur=e,a.shadowColor="black",a.beginPath(),a.arc(-r,-r,t,0,2*Math.PI,!0),a.closePath(),a.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(t){var e=this._createCanvas(),i=e.getContext("2d"),a=i.createLinearGradient(0,0,0,256);for(var r in e.width=1,e.height=256,t)a.addColorStop(+r,t[r]);return i.fillStyle=a,i.fillRect(0,0,1,256),this._grad=i.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var e=this._ctx;e.clearRect(0,0,this._width,this._height);for(var i,a=0,r=this._data.length;a<r;a++)i=this._data[a],e.globalAlpha=Math.max(i[2]/this._max,void 0===t?.05:t),e.drawImage(this._circle,i[0]-this._r,i[1]-this._r);var n=e.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),e.putImageData(n,0,0),this},_colorize:function(t,e){for(var i,a=0,r=t.length;a<r;a+=4)(i=4*t[a+3])&&(t[a]=e[i],t[a+1]=e[1+i],t[a+2]=e[2+i])},_createCanvas:function(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}}}(i={exports:{}},i.exports),i.exports),a="yymap-heatmap",n="0.0.5",o=function(t,e,i){return e&&h(t.prototype,e),i&&h(t,i),t};function h(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function u(t,e,i){null===t&&(t=Function.prototype);var a=Object.getOwnPropertyDescriptor(t,e);if(void 0===a){var r=Object.getPrototypeOf(t);return null===r?void 0:u(r,e,i)}if("value"in a)return a.value;var n=a.get;return void 0!==n?n.call(i):void 0}function c(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 d(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}var P=e.getNamespace().maptalks,l={max:1,gradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},radius:15,blur:15,minOpacity:.05};function f(t){if(Array.isArray(t[0])){var i=[];return t.forEach(function(t){var e=void 0;e=t instanceof P.Coordinate?[t.x,t.y]:t,i.push(e)}),i}var e=void 0;if(t instanceof P.Coordinate)t.x,t.y;else e=t;return e}var p,_,y=(p=P.Layer,c(v,p),o(v,[{key:"getData",value:function(){return this._heats}},{key:"setData",value:function(t){return t=f(t),this._heats=t||[],this.redraw()}},{key:"addData",value:function(t){return t?((t=f(t))[0]&&Array.isArray(t[0])?P.Util.pushIn(this._heats,t):this._heats.push(t),this.redraw()):this}},{key:"onConfig",value:function(t){for(var e in t)if(l[e])return this.redraw();return this}},{key:"setOpacity",value:function(t){return u(v.prototype.__proto__||Object.getPrototypeOf(v.prototype),"setOpacity",this).call(this,t),this.redraw(),this}},{key:"redraw",value:function(){var t=this._getRenderer();return t&&(t.clearHeatCache(),t.setToRedraw()),this}},{key:"isEmpty",value:function(){return!this._heats.length}},{key:"clear",value:function(){return this._heats=[],this.redraw(),this.fire("clear"),this}},{key:"toJSON",value:function(t){t=t||{};var e={type:this.getJSONType(),id:this.getId(),options:this.config()},i=this.getData();if(t.clipExtent){var a=new P.Extent(t.clipExtent),r=this._getHeatRadius();r&&(a=a._expand(r));for(var n=[],o=0,s=i.length;o<s;o++)a.contains(new P.Coordinate(i[o][0],i[o][1]))&&n.push(i[o]);e.data=n}else e.data=i;return e}},{key:"_getHeatRadius",value:function(){return this._getRenderer()?this._getRenderer()._heatRadius:null}}],[{key:"fromJSON",value:function(t){return t&&"HeatLayer"===t.type?new v(t.id,t.data,t.options):null}}]),v);function v(t,e,i){r(this,v),Array.isArray(e)||(i=e,e=null);var a=d(this,(v.__proto__||Object.getPrototypeOf(v)).call(this,t,i));return a._heats=e||[],a}function g(){return r(this,g),d(this,(g.__proto__||Object.getPrototypeOf(g)).apply(this,arguments))}y.mergeOptions(l),y.registerJSONType("HeatLayer"),y.registerRenderer("canvas",(_=P.renderer.CanvasRenderer,c(g,_),o(g,[{key:"draw",value:function(){var e=this.getMap(),t=this.layer,i=e.getContainerExtent(),a=this.prepareCanvas(),r=i;if(a){if(!(a=a.convertTo(function(t){return e._pointToContainerPoint(t)})).intersects(i))return void this.completeRender();r=i.intersection(a)}this._heater||(this._heater=s(this.canvas)),this._heater.radius(t.options.radius||this._heater.defaultRadius,t.options.blur),t.options.gradient&&this._heater.gradient(t.options.gradient),this._heater.max(t.options.max),this._heatViews||(this._heatViews=[]);var n=t.getData();if(0!==n.length){var o=this._heatData(n,r);0<this._heater._width&&0<this._heater._height&&this._heater.data(o).draw(t.options.minOpacity),this.completeRender()}else this.completeRender()}},{key:"drawOnInteracting",value:function(){this.draw()}},{key:"_heatData",value:function(t,e){var i=this.getMap(),a=this.layer,r=i.getProjection(),n=[],o=this._heater._r,s=void 0===a.options.max?1:a.options.max,h=P.Util.isNil(a.options.maxZoom)?i.getMaxZoom():a.options.maxZoom,u=1/Math.pow(2,Math.max(0,Math.min(h-i.getZoom(),12))),c=o/2,d=[],l=i.offsetPlatform(),f=l.x%c,p=l.y%c,_=void 0,y=void 0,v=void 0,g=void 0,m=void 0,w=void 0;e=e.expand(o).convertTo(function(t){return new P.Point(i._containerPointToPrj(t))}),this._heatRadius=o;for(var x=0,O=t.length;x<O;x++)_=t[x],this._heatViews[x]||(this._heatViews[x]=r.project(new P.Coordinate(_[0],_[1]))),y=this._heatViews[x],e.contains(y)&&(y=i._prjToContainerPoint(y),g=Math.floor((y.x-f)/c)+2,m=Math.floor((y.y-p)/c)+2,w=(void 0!==_.alt?_.alt:void 0!==_[2]?+_[2]:1)*u,d[m]=d[m]||[],(v=d[m][g])?(v[0]=(v[0]*v[2]+y.x*w)/(v[2]+w),v[1]=(v[1]*v[2]+y.y*w)/(v[2]+w),v[2]+=w):d[m][g]=[y.x,y.y,w]);for(var b=0,C=d.length;b<C;b++)if(d[b])for(var R=0,k=d[b].length;R<k;R++)(v=d[b][R])&&n.push([Math.round(v[0]),Math.round(v[1]),Math.min(v[2],s)]);return n}},{key:"onZoomEnd",value:function(){delete this._heatViews,u(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"onZoomEnd",this).apply(this,arguments)}},{key:"onResize",value:function(){if(this.canvas){var t=this.getMap().getSize(),e=t.width,i=t.height;this._heater._canvas.width=e,this._heater._canvas.height=i,this._heater.resize()}u(g.prototype.__proto__||Object.getPrototypeOf(g.prototype),"onResize",this).apply(this,arguments)}},{key:"onRemove",value:function(){this.clearHeatCache(),delete this._heater}},{key:"clearHeatCache",value:function(){delete this._heatViews}}]),g)),null!=console&&console.log(a+","+n),t.HeatLayer=y,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "yymap-heatmap",
"version": "0.0.4",
"version": "0.0.5",
"description": "A heatmap layer plugin for YYMap.js. ",

@@ -5,0 +5,0 @@ "main": "dist/yymap-heatmap.min.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc