Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ldmap

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ldmap - npm Package Compare versions

Comparing version 0.0.86 to 0.0.87

2

core/utils.js

@@ -1,1 +0,1 @@

function b(c){var a=Math.floor(Math.random()*1e7),b=new Date().getTime();return c+'_'+b+'_'+a}function l(d,c){c||(c=p(d.target)),c=p(c);var i=c.width(),j=c.height(),e=c.offset(),g=e.left,h=e.top,a,b;if(d.type.indexOf('mouse')!==-1)return a=d.x||d.pageX,b=d.y||d.pageY,[a-g,b-h];var f=window.event.touches[0];return a=f.pageX-g,b=f.pageY-h,a=a<i?a:i,a=a>0?a:1,b=b<j?b:j,b=b>0?b:1,[a,b]}function c(e){var c=e.length,a=0,d=n.LatLng.DEG_TO_RAD,f,g;if(c>2){for(var b=0;b<c;b++)f=e[b],g=e[(b+1)%c],a+=(g.lng-f.lng)*d*(2+Math.sin(f.lat*d)+Math.sin(g.lat*d));a=a*6378137*6378137/2}return Math.abs(a)}function d(b){var c=0,d=b.length;for(var a=0;a<d;a++){var e=(a+1)%d;c+=b[a].distanceTo(b[e])}return c}function e(d,e,f){var a=e.target,b=a.__data,c='child-'+d;f.fire(c,{layer:a,data:b})}function f(a,b,c,d){return typeof a==='function'?a(b,c,d):a}function g(e,h){var f,a,b,c,d=0;for(var g in e)f=e[g],a=f[h],d===0&&(b=c=a),b=Math.min(b,a),c=Math.max(c,a),d++;return[b,c]}function h(b,c){if(!b)return console.log('节点不存在');for(var a in c)b.style[a]=c[a]}function i(a){return typeof a==='number'&&(a=a.toString()),a.length>7?a.substring(0,7):a}function j(a,b,c){return a=i(a),c?'<a href="#'+a+'">'+a+'</a><br>':'<div style="'+u+'"> <div style="'+u+'">'+b+': </div> <a href="#'+a+'" style="'+v+'">'+a+'</a> </div><br>'}function k(a){var e=typeof a==='array',b,c='';for(var d in a){if(b=a[d],typeof b==='object')continue;c+=j(b,d,e)}return c}var a=require('aliyun-map-utils'),m=require('./l_utils'),n=require('leaflet'),o=n.dmap=n.dmap||{},p=require('jquery'),q=require('./projection'),r=require('./curve_util'),s=['click','mousedown','mouseup','mouseover','mouseout'],t=['click','mouseover','mouseout'],u='margin-right:5px; color:#999;white-space:nowrap; display:inline-block;',v='white-space:nowrap;color:#fff;display:inline-block;font-weight:bold;text-decoration:none;';module.exports=o.Utils=a.merge(a,q,r,m,{getId:b,getPt:l,getRange:g,geodesicArea:c,getLengthPolyline:d,popupFromObject:k,fireEvent:e,getValue:f,applyCss:h,EVENTS:s,EVENTSBasic:t})
function b(c){var a=Math.floor(Math.random()*1e7),b=new Date().getTime();return c+'_'+b+'_'+a}function l(d,c){c||(c=p(d.target)),c=p(c);var i=c.width(),j=c.height(),e=c.offset(),g=e.left,h=e.top,a,b;if(d.type.indexOf('mouse')!==-1)return a=d.x||d.pageX,b=d.y||d.pageY,[a-g,b-h];var f=window.event.touches[0];return a=f.pageX-g,b=f.pageY-h,a=a<i?a:i,a=a>0?a:1,b=b<j?b:j,b=b>0?b:1,[a,b]}function c(e){var c=e.length,a=0,d=n.LatLng.DEG_TO_RAD,f,g;if(c>2){for(var b=0;b<c;b++)f=e[b],g=e[(b+1)%c],a+=(g.lng-f.lng)*d*(2+Math.sin(f.lat*d)+Math.sin(g.lat*d));a=a*6378137*6378137/2}return Math.abs(a)}function d(b){var c=0,d=b.length;for(var a=0;a<d;a++){var e=(a+1)%d;c+=b[a].distanceTo(b[e])}return c}function e(d,e,f){var a=e.target,b=a.__data,c='child-'+d;f.fire(c,{layer:a,data:b})}function f(a,b,c,d){return typeof a==='function'?a(b,c,d):a}function g(e,h){var f,a,b,c,d=0;for(var g in e)f=e[g],a=f[h],d===0&&(b=c=a),b=Math.min(b,a),c=Math.max(c,a),d++;return[b,c]}function h(b,c){if(!b)return console.log('节点不存在');for(var a in c)b.style[a]=c[a]}function i(a){return typeof a==='number'&&(a=a.toString()),a.length>20?a.substring(0,20):a}function j(a,b,c){return a=i(a),c?'<a href="#'+a+'">'+a+'</a><br>':'<div style="'+u+'"> <div style="'+u+'">'+b+': </div> <a href="#'+a+'" style="'+v+'">'+a+'</a> </div><br>'}function k(a){var e=typeof a==='array',b,c='';for(var d in a){if(b=a[d],typeof b==='object')continue;c+=j(b,d,e)}return c}var a=require('aliyun-map-utils'),m=require('./l_utils'),n=require('leaflet'),o=n.dmap=n.dmap||{},p=require('jquery'),q=require('./projection'),r=require('./curve_util'),s=['click','mousedown','mouseup','mouseover','mouseout'],t=['click','mouseover','mouseout'],u='margin-right:5px; color:#999;white-space:nowrap; display:inline-block;',v='white-space:nowrap;color:#fff;display:inline-block;font-weight:bold;text-decoration:none;';module.exports=o.Utils=a.merge(a,q,r,m,{getId:b,getPt:l,getRange:g,geodesicArea:c,getLengthPolyline:d,popupFromObject:k,fireEvent:e,getValue:f,applyCss:h,EVENTS:s,EVENTSBasic:t})

@@ -1,1 +0,1 @@

'use strict';function a(b){this.options=c.deepMerge(a.options,b),this.initialize(b)}var b=require('./../leaflet'),c=require('./../core/utils'),d=c.Grid,e=c.getColorFunc,f=require('bcore/event');a.options={clusterStepByZoom:1,isAutoUpdate:!0,isNeedAggregate:!0,shape:{type:'hex',rx:20,ry:18,mouseover:{fillOpacity:.8,color:'rgba(255,255,255,0.9)'},mouseout:{fillOpacity:1,color:'rgba(255,255,255,0.0)'},style:{weight:0,fillOpacity:1,color:'rgba(255,255,255,0.0)'},click:{}},color:e('rgba(62,18,0,0.8)','rgba(255,208,122,0.8)','hsl','linear.Out.1.4'),scale:function(a){return 1},value:function(a,b,c){return Math.min(1,a.length/40)},lng:c.getLng,lat:c.getLat,popup:function(a){return'区域内有: '+a.length+'点'}},a=f.extend(a,{initialize:function(a){this.events={'grid-resize':{desc:'格子大小发生变化'},'grid-mouseover':{desc:'鼠标移至格子范围'},'grid-dblclick':{desc:'双击格子'},'grid-mouseout':{desc:'鼠标移出格子范围'},'grid-click':{desc:'点击某个格子'}},this.gridMap={},this.aggregatedData={},this.getMax=a.getMax,this.getColor=c.getColorFunc(a.shape.color||a.color),this.getScale=c.getColorFunc(a.shape.scale||a.scale),this.isable=!0},addTo:function(a){if(this._map||!a)return;this._map=a,this.initDataProcesser(),this._data&&this.updateZoom()},initDataProcesser:function(){var a=this._map,c=this.options.shape;this.gridEncoder=new d().transform(function(i,m){var d=a.getSize(),e=d.x/2,f=d.y/2,h=e-i,j=f+m,k=e+i,l=f-m,g=a.containerPointToLatLng(b.point(h,j)),c=a.containerPointToLatLng(b.point(k,l));return{dlat:c.lat-g.lat,dlng:c.lng-g.lng}}).shape(c.type).rx(c.rx).ry(c.ry).update(),this.initEventsMap()},initEventsMap:function(){var a=this;this._map.on('moveend',function(){this.render()}.bind(this)).on('zoomend',function(){a.updateZoom()})},updateZoom:function(){var a=this.options,d=a.clusterStepByZoom,b=this._map;if(a.isNeedAggregate){var e=b.getZoom(),c=Math.floor(e/d);if(c===this.zoomLevel)return;b.closePopup(),this.gridEncoder.update(),this.zoomLevel=c,this.clean(),this.aggregate(),this.fire('grid-resize'),this._updateTransformOrigin()}},aggregate:function(){if(!this.isable)return;var b=this.gridEncoder,a=this.options,f=this._data,d=a.lat,e=a.lng;this.aggregatedData=c.mapReduce(this._data,{map:function(c,a){return{key:b.encode(d(a),e(a)),value:a}}})},getBounds:function(){var c=this._map.getBounds(),a=c._southWest,b=c._northEast,d=.5*(b.lat-a.lat),e=.5*(b.lng-a.lng);return{latMin:a.lat-d,latMax:b.lat+d,lngMin:a.lng-e,lngMax:b.lng+e}},clean:function(){var a=this.gridMap,c=this._map;for(var b in a){var d=a[b];c.removeLayer(d),delete a[b]}},disable:function(){this.isable=!1,this.clean()},enable:function(){this.isable=!0,this.draw()},link:function(){},updateShape:function(){this.clean();var b=this.options.shape,c=b.type,d=b.rx,e=b.ry,a=this.gridEncoder;this._map.closePopup(),a.shape(c),a.rx(d),a.ry(e),a.update(),this.aggregate(),this.draw()},updateColor:function(a,h,i,j){a||(a=this.options.color);var e=this.getColor=c.getColorFunc(a,h,i,j),b=this.gridMap,d,f;for(var g in b)d=b[g],f=d._value,d.setStyle({fillColor:e(f)})},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.updateColor(),this.updateShape()},updateScale:function(a){if(!a)return;this.scaleGridFunc=function(e,f){if(!e)return;var b=e._container;this._updateTranformOriginGird(b);var c=a(f),d='scale3d('+c+','+c+',1)';b.style.transform=d,b.style['-webkit-transform']=d,this.getScale=a}},_updateTranformOriginGird:function(b){if(!b)return;var a=b.getBBox(),c=a.width/2+a.x+'px '+(a.height/2+a.y)+'px 0px';b.style['transform-origin']=c,b.style['-webkit-transform-origin']=c},_updateTransformOrigin:function(){if(!this.scaleGridFunc)return;var a=this.gridMap,b=this;setTimeout(function(){for(var c in a)b._updateTranformOriginGird(a[c]._container)})},data:function(b){if(!b)return this._data;this._data=b;var a=this.options;a.isAutoUpdate&&this._map&&this.aggregate(),this.updateColor();var c=a.shape},render:function(a){a&&this.data(a),this.draw()},each:function(d){var a=this.gridMap;for(var b in a){var c=a[b];d(c,b)}},draw:function(){if(!this.isable)return;var f=this.drawid='id_'+Math.floor(Math.random()*1e10),j=this.options,u=this.gridEncoder,p=j.shape.style,r=this.getColor,t=j.value,k=this.aggregatedData,c=this.gridMap,i=this._map,e=this.getBounds(),a,w=e.latMax,x=e.latMin,y=e.lngMax,z=e.lngMin;for(var d in k){var s=k[d],l=u.decode(d),m=l.center,v=l.pts,n=m[0],o=m[1];if(n<x||o<z||n>w||o>y)continue;var h=t(s),q=r(h);a=c[d],a?(a.setStyle({fillColor:q}),a._drawid=f):(p.fillColor=q,a=c[d]=b.polygon(v,p).addTo(i),a._value=h,a._gridid=d,a._drawid=f,this.initEventsGrid(a),this.scaleGridFunc&&this.scaleGridFunc(a,h))}for(var g in c)c[g]._drawid!==f&&(i.removeLayer(c[g]),delete c[g]);this._updateTransformOrigin()},initEventsGrid:function(a){var c=this,n=this.aggregatedData,g=this.options.shape,e=g.click||{},m=g.mouseover||{},i=g.mouseout||{},h=a._gridid,k=this._map,l=n[h],d={gridid:h,data:l,layer:a},f=a.getBounds(),o=f._northEast.lat,p=(f._southWest.lng+f._northEast.lng)/2,q=b.latLng(o,p),j;this.options.popup&&(j=this.options.popup(l)),a.on('mouseover',function(b){m&&a.setStyle(m),c.fire('grid-mouseover',d),a.bringToFront()}).on('mouseout',function(b){i&&a.setStyle(i),c.fire('grid-mouseout',d)}).on('mousedown',function(b){e&&a.setStyle(e),c.fire('grid-mousedown',d),k.closePopup(),j&&setTimeout(function(){k.openPopup(j,q)},10)}).on('click',function(){e&&a.setStyle(e),c.fire('grid-click',d)}).on('dblclick',function(a){c.fire('grid-dblclick',d)})}});var g=b.dmap=b.dmap||{};g.HeatmapGrid=a,g.heatmapGrid=function(b){return a(b)},module.exports=a
'use strict';function a(b){this.options=c.deepMerge(a.options,b),this.initialize(b)}var b=require('./../leaflet'),c=require('./../core/utils'),d=c.Grid,e=c.getColorFunc,f=require('bcore/event');a.options={clusterStepByZoom:1,isAutoUpdate:!0,isNeedAggregate:!0,shape:{type:'hex',rx:20,ry:18,mouseover:{fillOpacity:.8,color:'rgba(255,255,255,0.9)'},mouseout:{fillOpacity:1,color:'rgba(255,255,255,0.0)'},style:{weight:0,fillOpacity:1,color:'rgba(255,255,255,0.0)'},click:{}},color:e('rgba(62,18,0,0.8)','rgba(255,208,122,0.8)','hsl','linear.Out.1.4'),scale:function(a){return 1},value:function(a,b,c){return Math.min(1,a.length/40)},lng:c.getLng,lat:c.getLat,popup:function(a){return'区域内有: '+a.length+'点'}},a=f.extend(a,{initialize:function(){var a=this.options;this.events={'grid-resize':{desc:'格子大小发生变化'},'grid-mouseover':{desc:'鼠标移至格子范围'},'grid-dblclick':{desc:'双击格子'},'grid-mouseout':{desc:'鼠标移出格子范围'},'grid-click':{desc:'点击某个格子'}},this.gridMap={},this.aggregatedData={},this.getMax=a.getMax,this.getScale=c.getColorFunc(a.shape.scale||a.scale),this.isable=!0},addTo:function(a){if(this._map||!a)return;this._map=a,this.initDataProcesser(),this._data&&this.updateZoom()},initDataProcesser:function(){var a=this._map,c=this.options.shape;this.gridEncoder=new d().transform(function(i,m){var d=a.getSize(),e=d.x/2,f=d.y/2,h=e-i,j=f+m,k=e+i,l=f-m,g=a.containerPointToLatLng(b.point(h,j)),c=a.containerPointToLatLng(b.point(k,l));return{dlat:c.lat-g.lat,dlng:c.lng-g.lng}}).shape(c.type).rx(c.rx).ry(c.ry).update(),this.initEventsMap()},initEventsMap:function(){var a=this;this._map.on('moveend',function(){this.render()}.bind(this)).on('zoomend',function(){a.updateZoom()})},updateZoom:function(){var a=this.options,d=a.clusterStepByZoom,b=this._map;if(a.isNeedAggregate){var e=b.getZoom(),c=Math.floor(e/d);if(c===this.zoomLevel)return;b.closePopup(),this.gridEncoder.update(),this.zoomLevel=c,this.clean(),this.aggregate(),this.fire('grid-resize'),this._updateTransformOrigin()}},aggregate:function(){if(!this.isable)return;var b=this.gridEncoder,a=this.options,f=this._data,d=a.lat,e=a.lng;this.aggregatedData=c.mapReduce(this._data,{map:function(c,a){return{key:b.encode(d(a),e(a)),value:a}}})},getBounds:function(){var c=this._map.getBounds(),a=c._southWest,b=c._northEast,d=.5*(b.lat-a.lat),e=.5*(b.lng-a.lng);return{latMin:a.lat-d,latMax:b.lat+d,lngMin:a.lng-e,lngMax:b.lng+e}},clean:function(){var a=this.gridMap,c=this._map;for(var b in a){var d=a[b];c.removeLayer(d),delete a[b]}},disable:function(){this.isable=!1,this.clean()},enable:function(){this.isable=!0,this.draw()},link:function(){},updateShape:function(){this.clean();var b=this.options.shape,c=b.type,d=b.rx,e=b.ry,a=this.gridEncoder;this._map.closePopup(),a.shape(c),a.rx(d),a.ry(e),a.update(),this.aggregate(),this.draw()},updateColor:function(a,h,i,j){a||(a=this.options.color);var e=this.getColor=c.getColorFunc(a,h,i,j),b=this.gridMap,d,f;for(var g in b)d=b[g],f=d._value,d.setStyle({fillColor:e(f)})},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.updateColor(),this.updateShape()},updateScale:function(a){if(!a)return;this.scaleGridFunc=function(e,f){if(!e)return;var b=e._container;this._updateTranformOriginGird(b);var c=a(f),d='scale3d('+c+','+c+',1)';b.style.transform=d,b.style['-webkit-transform']=d,this.getScale=a}},_updateTranformOriginGird:function(b){if(!b)return;var a=b.getBBox(),c=a.width/2+a.x+'px '+(a.height/2+a.y)+'px 0px';b.style['transform-origin']=c,b.style['-webkit-transform-origin']=c},_updateTransformOrigin:function(){if(!this.scaleGridFunc)return;var a=this.gridMap,b=this;setTimeout(function(){for(var c in a)b._updateTranformOriginGird(a[c]._container)})},data:function(b){if(!b)return this._data;this._data=b;var a=this.options;a.isAutoUpdate&&this._map&&this.aggregate(),this.updateColor();var c=a.shape},render:function(a){a&&this.data(a),this.draw()},each:function(d){var a=this.gridMap;for(var b in a){var c=a[b];d(c,b)}},draw:function(){if(!this.isable)return;var l=this.drawid='id_'+Math.floor(Math.random()*1e10),j=this.options,x=this.gridEncoder,u=j.shape.style,B=c.getColorFunc(j.shape.color||j.color),p=j.value,h=this.aggregatedData,f=this.gridMap,o=this._map,i=this.getBounds(),a,C=i.latMax,D=i.latMin,A=i.lngMax,y=i.lngMin,g,k;for(var d in h){var e=p(h[d]);g||(g=e),k||(k=e),g=Math.min(e,g),k=Math.max(e,k)}for(var d in h){var w=h[d],q=x.decode(d),r=q.center,z=q.pts,s=r[0],t=r[1];if(s<D||t<y||s>C||t>A)continue;var e=p(w)||0,n=(e-g)/(k-g)||0,v=B(n);a=f[d],a?(a.setStyle({fillColor:v}),a._drawid=l):(u.fillColor=v,a=f[d]=b.polygon(z,u).addTo(o),a._value=n,a._gridid=d,a._drawid=l,this.initEventsGrid(a),this.scaleGridFunc&&this.scaleGridFunc(a,n))}for(var m in f)f[m]._drawid!==l&&(o.removeLayer(f[m]),delete f[m]);this._updateTransformOrigin()},initEventsGrid:function(a){var c=this,n=this.aggregatedData,g=this.options.shape,e=g.click||{},m=g.mouseover||{},i=g.mouseout||{},h=a._gridid,k=this._map,l=n[h],d={gridid:h,data:l,layer:a},f=a.getBounds(),o=f._northEast.lat,p=(f._southWest.lng+f._northEast.lng)/2,q=b.latLng(o,p),j;this.options.popup&&(j=this.options.popup(l)),a.on('mouseover',function(b){m&&a.setStyle(m),c.fire('grid-mouseover',d),a.bringToFront()}).on('mouseout',function(b){i&&a.setStyle(i),c.fire('grid-mouseout',d)}).on('mousedown',function(b){e&&a.setStyle(e),c.fire('grid-mousedown',d),k.closePopup(),j&&setTimeout(function(){k.openPopup(j,q)},10)}).on('click',function(){e&&a.setStyle(e),c.fire('grid-click',d)}).on('dblclick',function(a){c.fire('grid-dblclick',d)})}});var g=b.dmap=b.dmap||{};g.HeatmapGrid=a,g.heatmapGrid=function(b){return a(b)},module.exports=a

@@ -5,3 +5,3 @@ {

"description": "2d map visualization lib",
"version": "0.0.86",
"version": "0.0.87",
"scripts": {

@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test"

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