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.67 to 0.0.68

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 k(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.toFixed(6):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="'+s+'"> <div style="'+s+'">'+b+': </div> <a href="#'+a+'" style="'+t+'">'+a+'</a> </div><br>'}function a(a){var d=typeof a==='array',e,b='';for(var c in a)e=a[c],b+=j(e,c,d);return b}var l=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='margin-right:5px; color:#999;white-space:nowrap; display:inline-block;',t='white-space:nowrap;color:#fff;display:inline-block;font-weight:bold;text-decoration:none;';module.exports=o.Utils=l.merge(l,q,r,m,{getId:b,getPt:k,getRange:g,geodesicArea:c,getLengthPolyline:d,popupFromObject:a,fireEvent:e,getValue:f,applyCss:h})
function b(c){var a=Math.floor(Math.random()*1e7),b=new Date().getTime();return c+'_'+b+'_'+a}function k(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.toFixed(6):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="'+s+'"> <div style="'+s+'">'+b+': </div> <a href="#'+a+'" style="'+t+'">'+a+'</a> </div><br>'}function a(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 l=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='margin-right:5px; color:#999;white-space:nowrap; display:inline-block;',t='white-space:nowrap;color:#fff;display:inline-block;font-weight:bold;text-decoration:none;';module.exports=o.Utils=l.merge(l,q,r,m,{getId:b,getPt:k,getRange:g,geodesicArea:c,getLengthPolyline:d,popupFromObject:a,fireEvent:e,getValue:f,applyCss:h})

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

function a(b){b=this.options=d.deepMerge(a.options,b),this.initialize(b)}var b=require('leaflet'),c=require('./flyingLinePath'),d=require('./../core/utils'),e=b.dmap=b.dmap||{},f=require('./../core/anim_view');a.options={isAutoStart:!1,lifeMin:0,lifeMax:1,isPopupHover:0,lifeEnd:'destroy',range:.8,lifeSpeed:.08,interactiveLine:{weight:5,color:'rgba(250,150,50,0.0)',colorHover:'rgba(250,150,50,0.1)'},displayLine:{weight:1}},a.options=d.deepMerge(f.options,a.options),a=f.extend(a,{isInit:!1,life:0,initialize:function(a){this._map&&this.addTo(this._map),this.id=this.options.id||d.getId('flyingLine'),this.isLive=!1,this.isLooping=!0},checkIfEnd:function(){this.life>=this.options.lifeMax+this.options.range&&this._onLifeEnd()},addTo:function(a){return this._map=a,this.init(),this.initEvents(),this},init:function(){if(this.isInit||!this._map)return;this.initInteractiveLine(),this.initDisplayLine(),this.isInit=!0},initDisplayLine:function(){throw'必须实现initDisplayLine方法'},initInteractiveLine:function(){var f=this.options,g=this._map,h=this._data,a=this,d=f.interactiveLine;if(!d)return;var e=this.interactivePath=new c(d);e.addTo(g);var b=e._path;b.setAttribute('fill','none'),b.setAttribute('stroke',d.color),b.setAttribute('stroke-width',d.weight),b.setAttribute('stroke-linecap','round'),b.setAttribute('stroke-linejoin','round'),e.on('mouseover',function(){b.setAttribute('stroke',d.colorHover),a.emit('flyingline-mouseover'),f.isPopupHover&&e.openPopup()}).on('mouseout',function(){b.setAttribute('stroke',d.color),f.isPopupHover&&e.closePopup(),a.emit('flyingline-mouseout')}).on('mousedown',function(){a.resume(),a.fireEvent('mouseout',e),a.emit('flyingline-mousedown')}).on('click',function(b){a.emit('flyingline-click',{data:a._data,visual:a,latlng:b.latlng})})},setPopupContent:function(a){this.interactivePath&&this.interactivePath.setPopupContent(a)},data:function(a){if(!(a&&a.from&&a.to))return console.log('无数据/数据格式有问题');this._data=a,this.updateData(a),this.bindPopup(),this.reset(),this.options.isAutoStart&&this.resume()},render:function(a){a&&this.data(a),this.draw()},draw:function(){this.fireEvent('lifestart',{latlng:this.displayPath.from,data:this._data}),this.startAnim()},initEvents:function(){this.on('update',this.updateLife.bind(this)).on('lifeEnd',function(b){var a=this.options.lifeEnd;return a==='loop'?this.restart():a==='hide'?this.hide():a==='destroy'?this.destroy():void 0})},updateLife:function(a){if(!this.isLive)return;this.updateInteractiveLine&&this.updateInteractiveLine(a),this.updateDisplayLine&&this.updateDisplayLine(a)},updateData:function(a){this.interactivePath&&this.interactivePath.data(a),this.displayPath&&this.displayPath.data(a)},bindPopup:function(a,b){if(a=a||this.bindHTML,!a)return;if(!this._data)return this.bindHTML=a;b=d.deepMerge({maxWidth:800,autoPan:!1},b),typeof a==='function'&&(a=a(this._data||{})),this.interactivePath.bindPopup(a,b),this.bindHTML=null},hide:function(){this.life=0,this.isLive=!1,this.interactivePath&&this.interactivePath.hide(),this.displayPath&&this.displayPath.hide(),this.fire('hide')},pause:function(){this.isLooping=!1,this.isLive=!1,cancelAnimationFrame(this.loopid),this.loopid=null,this.fire('pause')},resume:function(){if(this.isLive)return;var a=this.options;setTimeout(function(){}.bind(this)),this.isLive=!0,this.loop(),this.fire('resume')},loop:function(){if(!this.isLooping)return;this._updateLife(),this.loopid=requestAnimationFrame(this.loop.bind(this))},isEnd:function(){return this.life>this.options.lifeMax},reset:function(){var a=this.options;this.life=a.lifeMin},destroy:function(){this.pause(),this.off(),this.life=0,this.isLive=!1,this.interactivePath&&this.interactivePath.destroy(),this.displayPath&&this.displayPath.destroy()}}),e.FlyingLine=a,e.flyingLine=function(b){return new a(b)},module.exports=a
function a(b){b=this.options=d.deepMerge(a.options,b),b.interactiveLine.kHeight=b.kHeight,b.displayLine.kHeight=b.kHeight,this.initialize(b)}var b=require('leaflet'),c=require('./flyingLinePath'),d=require('./../core/utils'),e=b.dmap=b.dmap||{},f=require('./../core/anim_view');a.options={isAutoStart:!1,lifeMin:0,lifeMax:1,isPopupHover:0,lifeEnd:'destroy',range:.8,lifeSpeed:.08,kHeight:.5,interactiveLine:{weight:5,color:'rgba(250,150,50,0.0)',colorHover:'rgba(250,150,50,0.1)'},displayLine:{weight:1}},a.options=d.deepMerge(f.options,a.options),a=f.extend(a,{isInit:!1,life:0,initialize:function(a){this._map&&this.addTo(this._map),this.id=this.options.id||d.getId('flyingLine'),this.isLive=!1,this.isLooping=!0},checkIfEnd:function(){this.life>=this.options.lifeMax+this.options.range&&this._onLifeEnd()},addTo:function(a){return this._map=a,this.init(),this.initEvents(),this},init:function(){if(this.isInit||!this._map)return;this.initInteractiveLine(),this.initDisplayLine(),this.isInit=!0},initDisplayLine:function(){throw'必须实现initDisplayLine方法'},initInteractiveLine:function(){var f=this.options,g=this._map,a=this,b=f.interactiveLine;if(b.kHeight=f.kHeight,!b)return;var e=this.interactivePath=new c(b);e.addTo(g);var d=e._path;d.setAttribute('fill','none'),d.setAttribute('stroke',b.color),d.setAttribute('stroke-width',b.weight),d.setAttribute('stroke-linecap','round'),d.setAttribute('stroke-linejoin','round'),e.on('mouseover',function(c){d.setAttribute('stroke',b.colorHover),a.emit('mouseover',a.record),f.isPopupHover&&e.openPopup()}).on('mouseout',function(c){d.setAttribute('stroke',b.color),f.isPopupHover&&e.closePopup(),a.emit('mouseout',a.record)}).on('mousedown',function(b){a.resume(),a.fireEvent('mouseout',e),a.emit('mousedown',a.record)}).on('click',function(b){a.emit('click',a.record)})},setPopupContent:function(a){this.interactivePath&&this.interactivePath.setPopupContent(a)},data:function(a){if(!(a&&a.from&&a.to))return console.log('无数据/数据格式有问题');this._data=a,this.updateData(a),this.bindPopup(),this.reset(),this.options.isAutoStart&&this.resume(),this.record={data:a,layer:this}},render:function(a){a&&this.data(a),this.draw()},draw:function(){this.fireEvent('lifestart',{latlng:this.displayPath.from,data:this._data}),this.startAnim()},initEvents:function(){this.on('update',this.updateLife.bind(this)).on('lifeEnd',function(b){var a=this.options.lifeEnd;return a==='loop'?this.restart():a==='hide'?this.hide():a==='destroy'?this.destroy():void 0})},updateOptions:function(a){a=this.options=d.deepMerge(this.options,a),this.updateOptionsInteractiveLine&&this.updateOptionsInteractiveLine(),this.updateOptionsDisplayLine&&this.updateOptionsDisplayLine(),a.interactiveLine.kHeight=a.kHeight,this.interactivePath&&this.interactivePath.updateOptions(a.interactiveLine),a.displayLine.kHeight=a.kHeight,this.displayPath&&this.displayPath.updateOptions(a.displayLine)},updateLife:function(a){if(!this.isLive)return;this.updateInteractiveLine&&this.updateInteractiveLine(a),this.updateDisplayLine&&this.updateDisplayLine(a)},updateData:function(a){this.interactivePath&&this.interactivePath.data(a),this.displayPath&&this.displayPath.data(a)},bindPopup:function(a,b){if(a=a||this.bindHTML,!a)return;if(!this._data)return this.bindHTML=a;b=d.deepMerge({maxWidth:800,autoPan:!1},b),typeof a==='function'&&(a=a(this._data||{})),this.interactivePath.bindPopup(a,b),this.bindHTML=null},hide:function(){this.life=0,this.isLive=!1,this.interactivePath&&this.interactivePath.hide(),this.displayPath&&this.displayPath.hide(),this.fire('hide')},pause:function(){this.isLooping=!1,this.isLive=!1,cancelAnimationFrame(this.loopid),this.loopid=null,this.fire('pause')},resume:function(){if(this.isLive)return;var a=this.options;setTimeout(function(){}.bind(this)),this.isLive=!0,this.loop(),this.fire('resume')},loop:function(){if(!this.isLooping)return;this._updateLife(),this.loopid=requestAnimationFrame(this.loop.bind(this))},isEnd:function(){return this.life>this.options.lifeMax},reset:function(){var a=this.options;this.life=a.lifeMin},destroy:function(){this.pause(),this.off(),this.life=0,this.isLive=!1,this.interactivePath&&this.interactivePath.destroy(),this.displayPath&&this.displayPath.destroy()}}),e.FlyingLine=a,e.flyingLine=function(b){return new a(b)},module.exports=a

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

function a(b){b=this.options=c.deepMerge(a.options,b),this.initialize(b)}var b=require('leaflet'),c=require('./../core/utils'),d=require('./flyingLine'),e=require('./flyingLinePath');a.options={opacity:1,displayLine:{colorTo:'rgba(250,150,50,1)',colorFrom:'rgba(255,0,0,0)',colorNormal:'rgba(250,250,250,0.2)'}},a.options=c.deepMerge(d.options,a.options),a=d.extend(a,{initDisplayLine:function(){var d=this._map,h=this._data,c=this.displayPath=new e(this.options.displayLine);c.addTo(d);var i=c.id,b=c._path,f=this.options,g=c.linearGradientId;this.linearGradient=c.linearGradient;var a=f.displayLine;this.createStop('a',{offset:'0%','stop-color':a.colorNormal}).createStop('b',{offset:'0%','stop-color':a.colorNormal}).createStop('c',{offset:'0%','stop-color':a.colorFrom}).createStop('d',{offset:'0%','stop-color':a.colorTo}).createStop('e',{offset:'0%','stop-color':a.colorNormal}).createStop('f',{offset:'100%','stop-color':a.colorNormal}),b.setAttribute('pointer-events','none'),b.setAttribute('fill','none'),b.setAttribute('stroke','url(#'+g+')'),b.setAttribute('stroke-width',a.weight),b.setAttribute('stroke-linecap','round'),b.setAttribute('stroke-linejoin','round')},createStop:function(b,d){var e=this.id+'stop1',f=this['stop1'+b+'ID']=e+b,g='stop1'+b,h=this.linearGradient,a=this[g]=document.createElementNS('http://www.w3.org/2000/svg','stop');a.setAttribute('id',f);for(var c in d)a.setAttribute(c,d[c]);return h.appendChild(a),this},updateDisplayLine:function(a){if(!a)return;var e=this.options,d=e.range,c,b;if(d>a?(c=0,b=a):a<1?(c=a-d,b=a):a>1&&a<1+d&&(c=a-d,b=1),!b)return;c=Math.floor(c*100)+'%',b=Math.floor(b*100)+'%',this.stop1b&&this.stop1b.setAttribute('offset',c),this.stop1c&&this.stop1c.setAttribute('offset',c),this.stop1d&&this.stop1d.setAttribute('offset',b),this.stop1e&&this.stop1e.setAttribute('offset',b)},genOptions:function(){return a.prototype.options=c.deepMerge(d.prototype.genOptions(),a.prototype.options)}},d),a.prototype.genOptions();var f=b.dmap=b.dmap||{};f.FlyingLineGradient=a,f.flyingLineGradient=function(b){return new a(b)},module.exports=a
function a(b){b=this.options=c.deepMerge(a.options,b),b.interactiveLine.kHeight=b.kHeight,b.displayLine.kHeight=b.kHeight,this.initialize(b)}var b=require('leaflet'),c=require('./../core/utils'),d=require('./flyingLine'),e=require('./flyingLinePath');a.options={opacity:1,displayLine:{colorTo:'rgba(250,150,50,1)',colorFrom:'rgba(255,0,0,0)',colorNormal:'rgba(250,250,250,0.2)'}},a.options=c.deepMerge(d.options,a.options),a=d.extend(a,{initDisplayLine:function(){var d=this._map,h=this._data,b=this.displayPath=new e(this.options.displayLine);b.addTo(d);var i=b.id,c=b._path,f=this.options,g=b.linearGradientId;this.linearGradient=b.linearGradient;var a=f.displayLine;this.createStop('a',{offset:'0%','stop-color':a.colorNormal}).createStop('b',{offset:'0%','stop-color':a.colorNormal}).createStop('c',{offset:'0%','stop-color':a.colorFrom}).createStop('d',{offset:'0%','stop-color':a.colorTo}).createStop('e',{offset:'0%','stop-color':a.colorNormal}).createStop('f',{offset:'100%','stop-color':a.colorNormal}),c.setAttribute('pointer-events','none'),c.setAttribute('fill','none'),c.setAttribute('stroke','url(#'+g+')'),c.setAttribute('stroke-linecap','round'),c.setAttribute('stroke-linejoin','round')},updateOptionsDisplayLine:function(){var a=this.options.displayLine;this.stop1a&&this.stop1a.setAttribute('stop-color',a.colorNormal),this.stop1b&&this.stop1b.setAttribute('stop-color',a.colorNormal),this.stop1c&&this.stop1c.setAttribute('stop-color',a.colorFrom),this.stop1d&&this.stop1d.setAttribute('stop-color',a.colorTo),this.stop1e&&this.stop1e.setAttribute('stop-color',a.colorNormal),this.stop1f&&this.stop1f.setAttribute('stop-color',a.colorNormal)},createStop:function(b,d){var e=this.id+'stop1',f=this['stop1'+b+'ID']=e+b,g='stop1'+b,h=this.linearGradient,a=this[g]=document.createElementNS('http://www.w3.org/2000/svg','stop');a.setAttribute('id',f);for(var c in d)a.setAttribute(c,d[c]);return h.appendChild(a),this},updateDisplayLine:function(a){if(!a)return;var e=this.options,d=e.range,c,b;if(d>a?(c=0,b=a):a<1?(c=a-d,b=a):a>1&&a<1+d&&(c=a-d,b=1),!b)return;c=Math.floor(c*100)+'%',b=Math.floor(b*100)+'%',this.stop1b&&this.stop1b.setAttribute('offset',c),this.stop1c&&this.stop1c.setAttribute('offset',c),this.stop1d&&this.stop1d.setAttribute('offset',b),this.stop1e&&this.stop1e.setAttribute('offset',b)},genOptions:function(){return a.prototype.options=c.deepMerge(d.prototype.genOptions(),a.prototype.options)}},d),a.prototype.genOptions();var f=b.dmap=b.dmap||{};f.FlyingLineGradient=a,f.flyingLineGradient=function(b){return new a(b)},module.exports=a

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

var a=require('leaflet'),b=require('./../core/utils'),c=a.dmap=a.dmap||{},d=a.Path.extend({options:{weight:10,opacity:1,color:'blue',hPhi:.5},initialize:function(c){this.options=b.deepMerge(this.options,c),this.isInit=!1,a.Path.prototype.initialize.call(this,c)},initSvg:function(){if(this.isInit)return;var f=this.options,g=b.getId('flyingPath2d'),i=f.color,h=this.linearGradientId=g+'grad',d=document.getElementsByTagName('svg')[0];if(!d)return console.log('svg节点尚未建立');var c=document.getElementsByTagName('defs')[0];c||(c=document.createElementNS('http://www.w3.org/2000/svg','defs'),d.appendChild(c));var e=this._path;if(!e)return console.log('path不存在');var a=this.linearGradient=document.createElementNS('http://www.w3.org/2000/svg','linearGradient');this.direction==='left'&&(a.setAttribute('x1','100%'),a.setAttribute('y1','0%'),a.setAttribute('x2','0%'),a.setAttribute('y2','0%')),a.setAttribute('id',h),c.appendChild(a),this._init&&this._init(e,a),this.isInit=!0},data:function(b){if(!(b&&b.from&&b.to))return;this._data=b;var d=this.from=a.latLng(b.from.lat,b.from.lng),e=this.to=a.latLng(b.to.lat,b.to.lng);this._latlngs=[d,e];var c=this.linearGradient;e.lng>d.lng?(this.direction='right',c.setAttribute('x1','0%'),c.setAttribute('x2','100%')):(this.direction='left',c.setAttribute('x1','100%'),c.setAttribute('x2','0%')),this.wake(),this.updatePath(),this.redraw(),this.addEventsMap()},addTo:function(a){return a?(this._map=a,a.addLayer(this),this.initSvg(),this.updatePath(),this.redraw(),this):void 0},addEventsMap:function(){this._map.on('viewreset',this.updatePath.bind(this))},updatePath:function(){var d=this.from,c=this.to,g=this.options;if(!(d&&c))return;var e=this._map,j=g.hPhi,a=this.fromPt=e.latLngToLayerPoint([d.lat,d.lng]),b=this.toPt=e.latLngToLayerPoint([c.lat,c.lng]),i=(b.x+a.x)/2,f=(b.y+a.y)/2,k=b.x-a.x,h=k*j;f+=-Math.abs(h),this._customData='M'+a.x+' '+a.y+' '+'Q'+' '+i+' '+f+' '+b.x+' '+b.y,this.getPathString()},getPathString:function(){var a=this._customData;return a instanceof Array?a.join(' '):a},hide:function(){this._path.setAttribute('display','none')},wake:function(){this._path.setAttribute('display','block')},destroy:function(){var a=document.getElementsByTagName('defs')[0],b=document.getElementById(this.linearGradientId);b&&a&&a.removeChild(b);var e=this._path,c=e.parentNode,d=document.getElementsByTagName('svg')[0];if(c&&d)try{d.removeChild(c)}catch(a){}}});c.FlyingLinePath=d,c.flyingLinePath=function(a){return new c.FlyingLinePath(a)},module.exports=d
var a=require('leaflet'),b=require('./../core/utils'),c=a.dmap=a.dmap||{},d=a.Path.extend({options:{weight:10,opacity:1,color:'blue',kHeight:.5},initialize:function(c){this.options=b.deepMerge(this.options,c),this.isInit=!1,a.Path.prototype.initialize.call(this,c)},initSvg:function(){if(this.isInit)return;var f=this.options,g=b.getId('flyingPath2d'),i=f.color,h=this.linearGradientId=g+'grad',d=document.getElementsByTagName('svg')[0];if(!d)return console.log('svg节点尚未建立');var c=document.getElementsByTagName('defs')[0];c||(c=document.createElementNS('http://www.w3.org/2000/svg','defs'),d.appendChild(c));var e=this._path;if(!e)return console.log('path不存在');var a=this.linearGradient=document.createElementNS('http://www.w3.org/2000/svg','linearGradient');this.direction==='left'&&(a.setAttribute('x1','100%'),a.setAttribute('y1','0%'),a.setAttribute('x2','0%'),a.setAttribute('y2','0%')),a.setAttribute('id',h),c.appendChild(a),this._init&&this._init(e,a),this.isInit=!0},updateOptions:function(a){a=this.options=b.deepMerge(this.options,a),this._path.setAttribute('stroke-width',a.weight),this.updatePath(),this.redraw()},data:function(b){if(!(b&&b.from&&b.to))return;this._data=b;var d=this.from=a.latLng(b.from.lat,b.from.lng),e=this.to=a.latLng(b.to.lat,b.to.lng);this._latlngs=[d,e];var c=this.linearGradient;e.lng>d.lng?(this.direction='right',c.setAttribute('x1','0%'),c.setAttribute('x2','100%')):(this.direction='left',c.setAttribute('x1','100%'),c.setAttribute('x2','0%')),this.wake(),this.updatePath(),this.redraw(),this.addEventsMap()},addTo:function(a){return a?(this._map=a,a.addLayer(this),this.initSvg(),this.updatePath(),this.redraw(),this):void 0},addEventsMap:function(){this._map.on('viewreset',this.updatePath.bind(this)),this.updatePath()},updatePath:function(){var d=this.from,c=this.to,g=this.options;if(!(d&&c))return;var e=this._map,j=g.kHeight,a=this.fromPt=e.latLngToLayerPoint([d.lat,d.lng]),b=this.toPt=e.latLngToLayerPoint([c.lat,c.lng]),i=(b.x+a.x)/2,f=(b.y+a.y)/2,k=b.x-a.x,h=k*j;f+=-Math.abs(h),this._customData='M'+a.x+' '+a.y+' '+'Q'+' '+i+' '+f+' '+b.x+' '+b.y,this.getPathString()},getPathString:function(){var a=this._customData;return a instanceof Array?a.join(' '):a},hide:function(){this._path.setAttribute('display','none')},wake:function(){this._path.setAttribute('display','block')},destroy:function(){var a=document.getElementsByTagName('defs')[0],b=document.getElementById(this.linearGradientId);b&&a&&a.removeChild(b);var e=this._path,c=e.parentNode,d=document.getElementsByTagName('svg')[0];if(c&&d)try{d.removeChild(c)}catch(a){}}});c.FlyingLinePath=d,c.flyingLinePath=function(a){return new c.FlyingLinePath(a)},module.exports=d

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

function a(b){b=this.options=f.deepMerge(a.options,b)}var b=require('leaflet'),c=require('./flyingLineGradient'),d=require('./flyingLineDash'),e=require('bcore/event'),f=require('bcore/utils'),g=b.dmap=b.dmap||{};a.options={lineN:100,type:'gradient',flying:{lifeEnd:'hide'}},a=e.extend(a,{isInit:!1,isLive:!0,life:0,addTo:function(a){return this._map=a,this.init(),this.initEvents(),this},init:function(){var b=this.options,j=b.lineN,f=b.flying,g=this._map,h={gradient:c,dash:d}[b.type],i=this.unusing=[],l=this.using=[],k=this.lines=[],a;for(var e=0;e<j;e++)a=new h(f),a.addTo(g),this.initEventsLine(a),i.push(a),k.push(a);this.loop()},data:function(a){this._data=a},render:function(a){a&&this.data(a),this.draw()},draw:function(){var a=this._data,b,c,e=this.using,d=this.unusing;for(var f in a)b=a[f],d.length&&b&&(c=d.pop(),c.data(b),e.push(c))},initEvents:function(){},initEventsLine:function(a){a.on('lifeEnd',function(f){var d=!1,c=this.using;for(var b=c.length-1;b>=0;b--){var e=c[b];e===a&&(d=!0,c.splice(b,1))}d&&this.unusing.push(a)}.bind(this))},update:function(){this.updateLife()},loop:function(){this.update(),window.requestAnimationFrame(this.loop.bind(this))},updateLife:function(){var b=this.using,c;for(var a=b.length-1;a>=0;a--)c=b[a],c._updateLife()},each:function(a){}}),g.FlyingLines=a,g.flyingLine=function(b){return new a(b)},module.exports=a
function a(b){b=this.options=f.deepMerge(a.options,b)}var b=require('leaflet'),c=require('./flyingLineGradient'),d=require('./flyingLineDash'),e=require('bcore/event'),f=require('bcore/utils'),g=b.dmap=b.dmap||{};a.options={lineN:100,type:'gradient',flying:{lifeEnd:'hide',lifeSpeed:.01,kHeight:1.3,displayLine:{colorTo:'rgba(250,150,50,1)',colorFrom:'rgba(255,0,0,1)',colorNormal:'rgba(250,250,250,0.1)'},interactiveLine:{}}},a=e.extend(a,{isInit:!1,isLive:!0,life:0,addTo:function(a){return this._map=a,this.init(),this.initEvents(),this},init:function(){var b=this.options,f=b.lineN,g=b.flying,h=this._map,i={gradient:c,dash:d}[b.type],j=this.unusing=[];this.using=[];var k=this.lines=[],a;for(var e=0;e<f;e++)a=new i(g),a.addTo(h),this.initEventsLine(a),j.push(a),k.push(a);this.loop()},data:function(a){this._data=a},render:function(a){a&&this.data(a),this.draw()},draw:function(){var b=this._data,c,a,e=this.using,d=this.unusing;for(var f in b)c=b[f],d.length&&c&&(a=d.pop(),a.data(c),a.resume(),e.push(a))},checkLine:function(a,b,c){if(a.life<=a.options.lifeMax+a.options.range-a.options.lifeSpeed*2)return;this.disableLine(a,b,c)},disableLine:function(a,b,c){c.splice(b,1),a.pause(),a.hide(),this.unusing.push(a)},initEventsLine:function(b){var a=this;b.on('mouseover',function(c){b.pause(),a.emit('child-mouseover',c)}).on('mouseout',function(c){b.resume(),a.emit('child-mouseout',c)}).on('click',function(b){a.emit('child-click',b)})},update:function(){this.updateLife()},updateOptions:function(a){this.options=f.deepMerge(this.options,a),this.each(function(b){b.updateOptions(a.flying)})},initEvents:function(){},loop:function(){this.update(),window.requestAnimationFrame(this.loop.bind(this))},updateLife:function(){var b=this.using,c;for(var a=b.length-1;a>=0;a--)c=b[a],c.isLive&&c._updateLife(),this.checkLine(c,a,b)},each:function(a){return this.lines.forEach(a)}}),g.FlyingLines=a,g.flyingLine=function(b){return new a(b)},module.exports=a

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

"description": "2d map visualization lib",
"version": "0.0.67",
"version": "0.0.68",
"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