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.95 to 0.0.96

2

layer/areas.js

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

'use strict';function a(a,b,c,d,e){return typeof a==='function'?a(b,c,d,e):a}var b=require('./../leaflet'),c=require('./../core/utils'),d=c.isNone,e=require('./../core/utils').getColorFunc,f=e({from:'#002170',to:'#c5f2e7',easing:'Quadratic.Out.1.1',space:'rgb'}),g=b.Class.extend({includes:[b.Mixin.Events],addTo:function(a){return this._map=a,this.geojson&&this.initGeojson(),this},geoJson:function(a){if(!a)return;this.geojson=a;var b=this._map;if(!b)return;this.initGeojson()},initGeojson:function(){var a=this.options,d=this.genStyle(a.style),e=this.geojson,f=a.geoid.bind(a),g=this.layers=[],h=this,c=this.geojsonLayer=b.geoJson(e,{style:d,draggable:!1,onEachFeature:function(a,b){var c=f(a);g[c]=b,b.__feature=a,h.initEventChild(b,a)}});c.addTo(this._map),c.bringToBack(),this.initEventsPopup()},initEventChild:function(a,i){var b={feature:i,layer:a},e=this,j=this.options.popup,f=this._map,g=c.EVENTSBasic;g.forEach(function(c){a.on(c,function(){return a.__data&&(b.data=a.__data),e.fire('child-'+c,b),!0})});var h=this.options,d=h.style.hover;d&&a.on('mouseover',function(){f.closePopup(),a.setStyle(d)}).on('mouseout',function(){a.setStyle(a.__style)})},initEventsPopup:function(){var a=this._map,b=this.options.popup;this.each(function(d){if(!d)return;this.updatePopupPostion(d),c.initEventsPopup({parent:this,child:d,map:a,datas:[d.__feature,d.__data],popup:b})}.bind(this))},updatePopupPostion:function(d){var e=this._map,a=c.getTopPoint(d.__feature);d.popupPosition=b.latLng(a[1],a[0])},initialize:function(a){this.options=c.deepMerge(g.options,a)},getLayer:function(a){return a&&this.layers?this.layers[a]:void 0},genStyle:function(d,e,f,g,h){var b={};for(var c in d)b[c]=a(d[c],e,f,g,h);return b},each:function(c){if(!c)return;var a=this.layers;for(var b in a)c(a[b],b)},data:function(a){this._data=a,this.updateRange()},updateRange:function(){var g=this._data,e=this.options,k=e.value,f=e.filter,c,a,i,j,b=this.range=[];for(var h in g){if(c=g[h],a=k(c),d(a))continue;if(f&&!f(c))continue;typeof a!=='number'&&(a=parseFloat(a)),d(b[0])&&(b[0]=b[1]=a),i=b[0],j=b[1],a>j&&(b[1]=a),a<i&&(b[0]=a)}},render:function(a){a&&this.data(a),this.draw(),this.initEventsPopup()},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.draw()},draw:function(){var a,m,h,e=this._data,f={},b=this.options,c=b.filter,i=b.style,j=b.id.bind(b),k=b.value.bind(b);for(var l in e)a=e[l],m=j(a),f[m]=a;var n=this.layers,g,d=this.range;this.each(function(b,e){if(a=f[e]||{},c&&!c(a))return;h=k(a),g=this.genStyle(i,h,d[0],d[1]),b.setStyle(g),b.__style=g,b&&(b.__data=a)}.bind(this))},hide:function(){console.log('目前无效')},getBounds:function(a){return this._map?this.geojsonLayer.getBounds():void 0},destory:function(){this.geojsonLayer&&this._map.removeLayer(this.geojsonLayer)}});g.options={geoid:function(b){var c=b.id||b.adcode;if(c)return c;var a=b.properties;return a?a.id||a.adcode:void 0},id:function(a){return a.id||a.adcode},value:function(a){return a.value},style:{fillColor:function(a,b,d){if(!a)return'rgba(0,150,200,1)';var c=(a-b)/(d-b);return f(c)},color:'transparent',weight:2,opacity:1,fillOpacity:1,dashArray:null}};var h=b.dmap=b.dmap||{};h.Area=g,h.area=function(a){return new g(a)},module.exports=g
'use strict';function a(a,b,c,d,e){return typeof a==='function'?a(b,c,d,e):a}var b=require('./../leaflet'),c=require('./../core/utils'),d=c.isNone,e=require('./../core/utils').getColorFunc,f=e({from:'#002170',to:'#c5f2e7',easing:'Quadratic.Out.1.1',space:'rgb'}),g=b.Class.extend({includes:[b.Mixin.Events],addTo:function(a){return this._map=a,this.geojson&&this.initGeojson(),this},geoJson:function(a){if(!a)return;this.geojson=a;var b=this._map;if(!b)return;this.removeGeojson(),this.initGeojson()},removeGeojson:function(a){a=a||this.geojsonLayer,a&&this._map.removeLayer(a)},initGeojson:function(){var a=this.options,d=this.genStyle(a.style),e=this.geojson,f=a.geoid.bind(a),g=this.layers=[],h=this,c=this.geojsonLayer=b.geoJson(e,{style:d,draggable:!1,onEachFeature:function(a,b){var c=f(a);g[c]=b,b.__feature=a,h.initEventChild(b,a)}});c.addTo(this._map),c.bringToBack(),this.initEventsPopup()},initEventChild:function(a,i){var b={feature:i,layer:a},e=this,j=this.options.popup,f=this._map,g=c.EVENTSBasic;g.forEach(function(c){a.on(c,function(){return a.__data&&(b.data=a.__data),e.fire('child-'+c,b),!0})});var h=this.options,d=h.style.hover;d&&a.on('mouseover',function(){f.closePopup(),a.setStyle(d)}).on('mouseout',function(){a.setStyle(a.__style)})},initEventsPopup:function(){var a=this._map,b=this.options.popup;this.each(function(d){if(!d)return;this.updatePopupPostion(d),c.initEventsPopup({parent:this,child:d,map:a,datas:[d.__feature,d.__data],popup:b})}.bind(this))},updatePopupPostion:function(d){var e=this._map,a=c.getTopPoint(d.__feature);d.popupPosition=b.latLng(a[1],a[0])},initialize:function(a){this.options=c.deepMerge(g.options,a)},getLayer:function(a){return a&&this.layers?this.layers[a]:void 0},genStyle:function(d,e,f,g,h){var b={};for(var c in d)b[c]=a(d[c],e,f,g,h);return b},each:function(c){if(!c)return;var a=this.layers;for(var b in a)c(a[b],b)},data:function(a){this._data=a,this.updateRange()},updateRange:function(){var g=this._data,e=this.options,k=e.value,f=e.filter,c,a,i,j,b=this.range=[];for(var h in g){if(c=g[h],a=k(c),d(a))continue;if(f&&!f(c))continue;typeof a!=='number'&&(a=parseFloat(a)),d(b[0])&&(b[0]=b[1]=a),i=b[0],j=b[1],a>j&&(b[1]=a),a<i&&(b[0]=a)}},render:function(a){a&&this.data(a),this.draw(),this.initEventsPopup()},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.draw()},draw:function(){var a,m,h,e=this._data,f={},b=this.options,c=b.filter,i=b.style,j=b.id.bind(b),k=b.value.bind(b);for(var l in e)a=e[l],m=j(a),f[m]=a;var n=this.layers,g,d=this.range;this.each(function(b,e){if(a=f[e]||{},c&&!c(a))return;h=k(a),g=this.genStyle(i,h,d[0],d[1]),b.setStyle(g),b.__style=g,b&&(b.__data=a)}.bind(this))},hide:function(){console.log('目前无效')},getBounds:function(a){return this._map?this.geojsonLayer.getBounds():void 0},destory:function(){this.geojsonLayer&&this._map.removeLayer(this.geojsonLayer)}});g.options={geoid:function(b){var c=b.id||b.adcode;if(c)return c;var a=b.properties;return a?a.id||a.adcode:void 0},id:function(a){return a.id||a.adcode},value:function(a){return a.value},style:{fillColor:function(a,b,d){if(!a)return'rgba(0,150,200,1)';var c=(a-b)/(d-b);return f(c)},color:'transparent',weight:2,opacity:1,fillOpacity:1,dashArray:null}};var h=b.dmap=b.dmap||{};h.Area=g,h.area=function(a){return new g(a)},module.exports=g

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

function a(b){b=this.options=e.deepMerge(a.options,b)}function b(a){return a.type&&a.type.toLowerCase().indexOf('feature')!==-1||a.features}var c=require('./../leaflet'),d=require('bcore/event'),e=require('ldmap/core/utils'),f=c.dmap=c.dmap||{},g=require('./../render/leaflet_layer_konva');a.options={color:{from:'rgba(245,230,0,1)',to:'rgba(205,0,0, 0.6)',easing:'Linear.None.1.7',space:'rgb'},value:function(a){return a.value},geoId:function(a,b){return a.properties.id||b},lat:e.getLat,lng:e.getLng},a=d.extend(a,{addTo:function(a){return this._map=a,this.isable=!0,this.init(),this.initEvents(),this},geojson:function(a){},processGeoData:function(c){var d=this.features={},f=this.options,e=f.geoId,a;if(b(c)){var g=c.features;g.forEach(function(b,c){a=e(b,c),d[a]=b})}else c.forEach(function(b){var f=b.latlngs||b.coords||b.coordinates,c=[];f.forEach(function(a){c.push([getLng(a),getLat(a)])}),a=e(b),d[a]={type:'feature',geometry:{type:'LineString',coordinates:c}}})},each:function(){},init:function(){var b=this.options,d=b.lineN,e=b.flying,f=this._map,g={gradient:FlyingLineGradient,dash:FlyingLineDash}[b.type],h=this.unusing=[];this.using=[];var i=this.lines=[],a;for(var c=0;c<d;c++)a=new g(e),a.addTo(f),this.initEventsLine(a),h.push(a),i.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)},disable:function(){this.isable=!1},enable:function(){this.isable=!0},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=e.deepMerge(this.options,a),this.each(function(b){b.updateOptions(a.flying)})},initEvents:function(){},loop:function(){this.update(),this.isable&&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)},remove:function(){this.using=[],this.unusing=[];var a=this._map;this.lines.forEach(function(c){var a=c.displayPath;a&&a.destroy();var b=c.interactivePath;b&&b.destroy()}),this.disable(),this.lines=[],this._data=null},each:function(a){return this.lines.forEach(a)}}),f.LinesKonva=a,f.linesKonva=function(b){return new a(b)},module.exports=a
function b(a){a=this.options=f.deepMerge(b.options,a)}function g(a){return!a[0][0][0]}function c(a){return a.type&&a.type.toLowerCase().indexOf('feature')!==-1||a.features}var d=require('./../leaflet'),e=require('bcore/event'),f=require('./../core/utils'),a=f.isNone,h=f.fireEvent,i=require('konva'),j=d.dmap=d.dmap||{},k=require('./../render/leaflet_layer_konva'),l=f.getColorFunc({from:'rgba(245,230,0,1)',to:'rgba(205,0,0, 0.6)',none:'rgba(200,200,200, 0.6)',easing:'Linear.None.1.7',space:'rgb'});b.options={container:'.leaflet-overlay-pane',value:function(a){return a.value},lazyFresh:{transition:'opacity 0.1s'},popup:function(a){return'test'},blending:'source-over',color:function(a,b,d){if(!a)return l(null);var c=(a.value-b)/(d-b);return l(c)},id:function(a,b){return a.id||a[0]||b},style:{stroke:'#fff',strokeWidth:2,lineCap:'round',lineJoin:'round'},value:function(a){return a.value},geoId:function(a,b){return a.properties?a.properties.id||b:a.id||b},lat:f.getLat,lng:f.getLng},b=e.extend(b,{initCanvas:function(){var b=this._map,a=this.options,c=b.getSize(),d=new i.Stage({container:a.container,width:c.x,height:c.y}),e=this.kLeafLayer=new k(d,{transition:a.lazyFresh.transition,blending:a.blending,ptNPerLayer:a.ptNPerLayer});e.addTo(b)},addTo:function(a){return a?(a._map&&(a=a._map),this._map=a,this.isable=!0,this.initCanvas(),this.initEvents(),this.initEventsMap(),this):void 0},geojson:function(a){if(!a)return console.log('地理数据缺失');this._geodata=a,this.processGeoData(a),this.draw()},processGeoData:function(d){var e=this.features={},a=this.options,f=a.geoId,g=a.lng,h=a.lat,b;if(c(d)){var i=d.features;i.forEach(function(a,c){b=f(a,c),e[b]=a})}else d.forEach(function(a){var d=a.latlngs||a.coords||a.coordinates,c=[];d.forEach(function(a){c.push([g(a),h(a)])}),b=f(a),e[b]={type:'feature',geometry:{type:'LineString',coordinates:c}}})},draw:function(){var f=this,j=this.dataObj||{},e=this.features,i=this.layers={},h,c,d;this.lineIndex=0;for(var a in e){h=e[a].geometry,c=h.coordinates,d=j[a];var k=i[a]=[],b=0;g(c)?this.createLineAttr(c,a,b,d):c.forEach(function(c){if(Array.isArray(c[0]))return b++,f.createLineAttr(c,a,b,d);c.forEach(function(c){b++,f.createLineAttr(c,a,b,d)})})}this.kLeafLayer.stopLazyFresh(),this.kLeafLayer.lazyFresh()},createLineAttr:function(l,o,n,e){if(!this.isable)return;this.lineIndex+=1;var a=this.getChildOptions(),h=f.getValue(a.weight,e)||1;a.strokeWidth=h;var k=this._map.latLngToContainerPoint.bind(this._map),g=this.range||[],m=a.stroke=f.getValue(this.options.color,e,g[0],g[1]),b=a.points=[];l.forEach(function(c){var a=k(d.latLng(c[1],c[0]));b.push(a.x,a.y)});var c=Math.floor(b.length/4),j={x:b[c*2],y:b[c*2+1]};this.kLeafLayer.addOrSetShape({data:e,top:j,Constructor:i.Line,index:this.lineIndex,id:o+'-'+n,attrs:a})},getChildOptions:function(){var a=this.options;return a.style},updateRange:function(){var g=this._data,e=this.options,k=e.value,f=e.filter,d,b,i,j,c=this.range=[];for(var h in g){if(d=g[h],b=k(d),a(b))continue;if(f&&!f(d))continue;typeof b!=='number'&&(b=parseFloat(b)),a(c[0])&&(c[0]=c[1]=b),i=c[0],j=c[1],b>j&&(c[1]=b),b<i&&(c[0]=b)}},initEventsMap:function(){this._map.on('zoomend',this.draw.bind(this)).on('moveend',this.draw.bind(this))},initEvents:function(){var c=this,a,b=this.kLeafLayer.onKonva('dragstart',function(a){}).onKonva('mouseover touchstart',function(b){a=b.target,a.setAttrs({opacity:.8}),a.parent.draw()}).onKonva('mouseout',function(b){a=b.target,a.setAttrs({opacity:1}),a.parent.draw()}).onKonva('mouseout mouseup touchend',function(a){setTimeout(function(){b.enableMapEvents()})}).onKonva('mousedown touchstart',this.onMouseDown.bind(this)),d=['mouseout','mousedown','mouseover','mouseout','touchstart','touchend','touchup'];d.forEach(function(a){b.onKonva(a,function(b){h(a,b,c)})})},onMouseDown:function(g){var b=this.options,e=this._map,c=g.target,f=c.__data,a=b.popup;if(a&&(a=a.bind(b)),a||(a=b.popup,a&&(a=a.bind(b))),!a)return;popupText=a(f),setTimeout(function(){if(c){var a=c.__options.top,b=e.containerPointToLatLng(d.point(a.x,a.y));e.openPopup(popupText,d.latLng(b.lat,b.lng))}}.bind(this)),this.kLeafLayer.disableMapEvents()},each:function(a){},data:function(a){if(!a)return console.log('没数据...');this._data=a,this.processing(a),this.updateRange()},processing:function(b){var c=this.options.id,a,d,e=this.dataObj={};for(var f in b)a=b[f],d=c(a),e[d]=a},render:function(a){a&&this.data(a),this.draw()},disable:function(){this.isable=!1,this.kLeafLayer.disable()},enable:function(){this.isable=!0,this.kLeafLayer.enable()},update:function(){this.updateLife()},updateOptions:function(a){this.options=f.deepMerge(this.options,a),this.draw()},remove:function(){}}),j.LinesKonva=b,j.linesKonva=function(a){return new b(a)},module.exports=b

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

function a(a,b,c,d){return typeof a==='function'?a(b,c,d):a}var b=require('./../leaflet'),c=require('konva'),d=require('lodash'),e=require('./../render/leaflet_layer_konva'),f=require('./../core/utils'),g=f.getSprite,h=f.fireEvent,a=f.getValue,i=b.Class.extend({includes:[b.Mixin.Events],initialize:function(a){a=this.options=f.deepMerge(i.options,a),this.resetVariables()},resetVariables:function(){this.isable=!0},disable:function(){this.isable=!1,this.kLeafLayer.disable()},enable:function(){this.isable=!0,this.kLeafLayer.enable()},addTo:function(a){if(this._map||!a)return;this._map=a,this.initCanvas(),this.initEventsMap(),this.initEventsShapes()},initEventsShapes:function(){var c=this,e=this.options.hoverScale||1,a,b=this.kLeafLayer.onKonva('dragstart',function(a){}).onKonva('mouseover touchstart',function(b){a=b.target,a.setAttrs({opacity:.8}),a.parent.draw()}).onKonva('mouseout',function(b){a=b.target,a.setAttrs({opacity:1}),a.parent.draw()}).onKonva('mouseout mouseup touchend',function(a){setTimeout(function(){b.enableMapEvents()})}).onKonva('mousedown touchstart',this.onMouseDown.bind(this)),d=['mouseout','mousedown','mouseover','mouseout','touchstart','touchend','touchup'];d.forEach(function(a){b.onKonva(a,function(b){h(a,b,c)})})},onMouseDown:function(g){var c=this.options,e=this._map,d=g.target,f=d.__data,a=c.popup;if(a&&(a=a.bind(c)),a||(a=c.child.popup,a&&(a=a.bind(c.child))),!a)return;popupText=a(f),setTimeout(function(){if(d){var a=d.__options.top,c=e.containerPointToLatLng(b.point(a.x,a.y));e.openPopup(popupText,b.latLng(c.lat,c.lng))}}.bind(this)),this.kLeafLayer.disableMapEvents()},initCanvas:function(){var b=this._map,a=this.options,d=b.getSize(),f=new c.Stage({container:a.container,width:d.x,height:d.y}),g=this.kLeafLayer=new e(f,{transition:a.lazyFresh.transition,blending:a.blending,ptNPerLayer:a.ptNPerLayer});g.addTo(b)},data:function(a){this._data=a,this.updateDataZindex()},updateDataZindex:function(){var a=this.options,b=a.zIndex||a.child.zIndex;b&&(this._data=d.sortBy(this._data,b))},updateOptions:function(a){var b=this.kLeafLayer;b.resetOffset(),a=this.options=f.deepMerge(this.options,a),b.hideLayers(),b.updateOptions({transition:a.lazyFresh.transition,blending:a.blending,ptNPerLayer:a.ptNPerLayer}),this.draw()},updateFilter:function(a){if(!a||typeof a!=='function')return;this.options.filter=a,this.draw()},render:function(a){a&&this.data(a),a&&this.kLeafLayer.beginDraw(),this.draw(),a&&this.kLeafLayer.endDraw()},createShapeAttr:function(f,d){if(!this.isable)return;var e=this.options,p=a(e.from,f),l=a(e.to,f),u=a(e.id.bind(e),f,d),s=a(e.weight,f)||1,i=this._map.latLngToContainerPoint(b.latLng(p.lat,p.lng)),j=this._map.latLngToContainerPoint(b.latLng(l.lat,l.lng)),g=i.x,k=i.y,m=j.x,v=j.y,r=Math.abs(m-g),y=(i.x+j.x)/2,x=(i.y+j.y)/2-r*e.kHeight,h=m-g,q=v-k,w=a(e.color,f),o=[],n=e.kHeight;for(var d=0;d<=1;d+=.1)o.push(g+h*d,k+q*d-Math.abs(d*(1-d)*h*n));var t={x:g+h/2,y:k+q/2-Math.abs(.25*h*n)};return{data:f,Constructor:c.Line,index:d,id:u,top:t,attrs:{points:o,stroke:w,strokeWidth:s,lineCap:'round',lineJoin:'round'}}},draw:function(){var b=this._data;if(!(b&&this.isable))return;var d,f,c=this.kLeafLayer,e=this.options.filter;for(var a=b.length-1;a>-1;a--){if(d=b[a],e&&!e(d,a))continue;f=this.createShapeAttr(d,a),c.addOrSetShape(f)}c.stopLazyFresh(),c.lazyFresh()},initEventsMap:function(){this._map.on('zoomend',this.draw.bind(this)).on('moveend',this.draw.bind(this))},destroy:function(){this.kLeafLayer.destroy()},clean:function(){this.kLeafLayer.clean()}});i.options={zIndex:null,kHeight:.8,refreshInterval:1,ptNPerLayer:1e3,lazyFresh:{transition:'opacity 0.4s'},weight:function(a){return 4},id:function(a,b){return a.id||b},color:function(a){return'rgba(0,180,180,0.5)'},onPopupOpen:function(a,b){},from:f.getFrom,to:f.getTo,hoverScale:.2,blending:'lighter',container:'tilePane',sprite:{drawN:1.15,color:{from:'rgba(245,230,0,1)',to:'rgba(205,0,0, 0.6)',easing:'Linear.None.1.7',space:'rgb'}},child:{}};var j=b.dmap=b.dmap||{};j.LinkKonva=i,j.linkKonva=function(a){return new i(a)},module.exports=i
function a(a,b,c,d){return typeof a==='function'?a(b,c,d):a}var b=require('./../leaflet'),c=require('konva'),d=require('lodash'),e=require('./../render/leaflet_layer_konva'),f=require('./../core/utils'),g=f.getSprite,h=f.fireEvent,a=f.getValue,i=b.Class.extend({includes:[b.Mixin.Events],initialize:function(a){a=this.options=f.deepMerge(i.options,a),this.resetVariables()},resetVariables:function(){this.isable=!0},disable:function(){this.isable=!1,this.kLeafLayer.disable()},enable:function(){this.isable=!0,this.kLeafLayer.enable()},addTo:function(a){if(this._map||!a)return;this._map=a,this.initCanvas(),this.initEventsMap(),this.initEventsShapes()},initEventsShapes:function(){var c=this,e=this.options.hoverScale||1,a,b=this.kLeafLayer.onKonva('dragstart',function(a){}).onKonva('mouseover touchstart',function(b){a=b.target,a.setAttrs({opacity:.8}),a.parent.draw()}).onKonva('mouseout',function(b){a=b.target,a.setAttrs({opacity:1}),a.parent.draw()}).onKonva('mouseout mouseup touchend',function(a){setTimeout(function(){b.enableMapEvents()})}).onKonva('mousedown touchstart',this.onMouseDown.bind(this)),d=['mouseout','mousedown','mouseover','mouseout','touchstart','touchend','touchup'];d.forEach(function(a){b.onKonva(a,function(b){h(a,b,c)})})},onMouseDown:function(g){var c=this.options,e=this._map,d=g.target,f=d.__data,a=c.popup;if(a&&(a=a.bind(c)),a||(a=c.child.popup,a&&(a=a.bind(c.child))),!a)return;popupText=a(f),setTimeout(function(){if(d){var a=d.__options.top,c=e.containerPointToLatLng(b.point(a.x,a.y));e.openPopup(popupText,b.latLng(c.lat,c.lng))}}.bind(this)),this.kLeafLayer.disableMapEvents()},initCanvas:function(){var b=this._map,a=this.options,d=b.getSize(),f=new c.Stage({container:a.container,width:d.x,height:d.y}),g=this.kLeafLayer=new e(f,{transition:a.lazyFresh.transition,blending:a.blending,ptNPerLayer:a.ptNPerLayer});g.addTo(b)},data:function(a){this._data=a,this.updateDataZindex()},updateDataZindex:function(){var a=this.options,b=a.zIndex||a.child.zIndex;b&&(this._data=d.sortBy(this._data,b))},updateOptions:function(a){var b=this.kLeafLayer;b.resetOffset(),a=this.options=f.deepMerge(this.options,a),b.hideLayers(),b.updateOptions({transition:a.lazyFresh.transition,blending:a.blending,ptNPerLayer:a.ptNPerLayer}),this.draw()},updateFilter:function(a){if(!a||typeof a!=='function')return;this.options.filter=a,this.draw()},render:function(a){a&&this.data(a),a&&this.kLeafLayer.beginDraw(),this.draw(),a&&this.kLeafLayer.endDraw()},createShapeAttr:function(f,d){if(!this.isable)return;var e=this.options,p=a(e.from,f),l=a(e.to,f),u=a(e.id.bind(e),f,d),s=a(e.weight,f)||1,i=this._map.latLngToContainerPoint(b.latLng(p.lat,p.lng)),j=this._map.latLngToContainerPoint(b.latLng(l.lat,l.lng)),g=i.x,k=i.y,m=j.x,v=j.y,r=Math.abs(m-g),y=(i.x+j.x)/2,x=(i.y+j.y)/2-r*e.kHeight,h=m-g,q=v-k,w=a(e.color,f),o=[],n=e.kHeight;for(var d=0;d<=1;d+=.1)o.push(g+h*d,k+q*d-Math.abs(d*(1-d)*h*n));var t={x:g+h/2,y:k+q/2-Math.abs(.25*h*n)};return{data:f,Constructor:c.Line,index:d,id:u,top:t,attrs:{points:o,stroke:w,strokeWidth:s,lineCap:'round',lineJoin:'round'}}},draw:function(){var b=this._data;if(!(b&&this.isable))return;var d,f,c=this.kLeafLayer,e=this.options.filter;for(var a=b.length-1;a>-1;a--){if(d=b[a],e&&!e(d,a))continue;f=this.createShapeAttr(d,a),c.addOrSetShape(f)}c.stopLazyFresh(),c.lazyFresh()},initEventsMap:function(){this._map.on('zoomend',this.draw.bind(this)).on('moveend',this.draw.bind(this))},destroy:function(){this.kLeafLayer.destroy()},clean:function(){this.kLeafLayer.clean()}});i.options={zIndex:null,kHeight:.8,refreshInterval:1,ptNPerLayer:1e3,lazyFresh:{transition:'opacity 0.4s'},weight:function(a){return 4},id:function(a,b){return a.id||b},color:function(a){return'rgba(0,180,180,0.5)'},onPopupOpen:function(a,b){},from:f.getFrom,to:f.getTo,hoverScale:.2,blending:'lighter',container:'.leaflet-overlay-pane',sprite:{drawN:1.15,color:{from:'rgba(245,230,0,1)',to:'rgba(205,0,0, 0.6)',easing:'Linear.None.1.7',space:'rgb'}},child:{}};var j=b.dmap=b.dmap||{};j.LinkKonva=i,j.linkKonva=function(a){return new i(a)},module.exports=i

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

"description": "2d map visualization lib",
"version": "0.0.95",
"version": "0.0.96",
"scripts": {

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

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

function a(b,d){b.content.style.zIndex=1e3,this.options=c.deepMerge(a.options,d),this.stage=b}var b=require('bcore/event'),c=require('bcore/utils'),d=require('./../leaflet');a.options={transition:'opacity 0.4s',blending:'lighter',lazyFresh:!0,ptNPerLayer:1e3},a=b.extend(a,{beginDraw:function(){this.versionID=Math.random()},endDraw:function(){var a=this.shapes;for(var b in a){var c=a[b];c.__versionID!==this.versionID&&(c.destroy(),delete a[b])}this.lazyFresh()},clean:function(){var a=this.shapes;for(var b in a){var c=a[b];c.destroy(),delete a[b]}},cleanOld:function(){var c=this.versionID,b=this.cache,d,a,f;if(!(c&&b))return;for(var e in b)d=b[e],f=d.versionID,f!==c&&(a=d.visual,a&&(a.off&&a.off(),a.destroy&&a.destroy()),delete b[e])},addTo:function(a){this._map=a,this.resetVariables(),this.initEventsMap()},resetOffset:function(){this.pOffset=this.offset},disable:function(){this.isable=!1,this.stage.content.style.display='none'},enable:function(){this.isable=!0,this.stage.content.style.display='block'},resetVariables:function(){this.isable=!0,this.shapes={},this.layers=[],this.offset={x:0,y:0},this.pOffset={x:0,y:0}},add:function(a){this.stage.add(a)},addOrSetShape:function(a){var g=a.Constructor,h=a.index,e=a.attrs,i=a.data,c=a.id,d=this.shapes;if(d[c])return d[c].__options=a,d[c].setAttrs(e);var b=new g(e),f=this.getOrAddLayer(h);f.getCanvas().getContext('2d').globalCompositeOperation=this.options.blending,f.add(b),d[c]=b,b.__options=a,b.__versionID=this.versionID,b.__data=i},getOrAddLayer:function(b){if(!this.isable)return;b=Math.floor(b/this.options.ptNPerLayer);var c=this.layers,a=c[b];return a?a:(a=new Konva.Layer,c[b]=a,this.stage.add(a),a.canvas._canvas.style.zIndex=1e3-b,a)},fresh:function(){this.layers.forEach(function(a){a.draw()})},lazyFresh:function(){if(!this.isable)return;this.lazyFreshDraw(0)},lazyFreshDraw:function(b){var c=this;b=b||0;var a=this.layers[b];if(!a)return window.requestAnimationFrame(this.lazyFreshDone.bind(this));a.draw(),this.resetPos(a.canvas._canvas,{x:c.offset.x-c.pOffset.x,y:c.offset.y-c.pOffset.y}),a.canvas._canvas.style.opacity=1,a.canvas._canvas.style.transition=this.options.lazyFresh.transition,b++,this.lazyFreshId=window.requestAnimationFrame(function(){this.lazyFreshDraw(b)}.bind(this))},lazyFreshDone:function(){this.resetPos(this.stage.content),this.layers.forEach(function(a){d.DomUtil.setPosition(a.canvas._canvas,{x:0,y:0})})},resetPos:function(b,a){if(a=a||d.DomUtil.getPosition(this._map.getPanes().mapPane),!a)return;d.DomUtil.setPosition(b,{x:-a.x,y:-a.y})},stopLazyFresh:function(){if(!this.lazyFreshId)return;window.cancelAnimationFrame(this.lazyFreshId),this.lazyFreshId=null},hideLayers:function(){this.layers.forEach(function(a){a.canvas._canvas.style.opacity=0})},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.updateBlending()},updateBlending:function(b){var a=this.options;this.layers.forEach(function(b){b.getCanvas().getContext('2d').globalCompositeOperation=a.blending})},initEventsMap:function(){var a=this,b=this._map;b.on('zoomstart',function(){a.hideLayers(),a.stopLazyFresh()}).on('movestart',function(){a.stopLazyFresh()}).on('moveend',function(){a.pOffset=a.offset,a.offset=d.DomUtil.getPosition(b.getPanes().mapPane)}).on('resize',function(){console.log('resize')})},onKonva:function(a,b){return this.stage.on(a,b),this},enableMapEvents:function(){var a=this.stage.content;d.DomEvent.off(a,'click',d.DomEvent._fakeStop),d.DomEvent.off(a,'mousedown',d.DomEvent.stopPropagation),d.DomEvent.off(a,'mousemove',d.DomEvent.stopPropagation),this._map.dragging.enable()},disableMapEvents:function(){var a=this.stage.content;d.DomEvent.on(a,'click',d.DomEvent._fakeStop),d.DomEvent.on(a,'mousedown',d.DomEvent.stopPropagation),d.DomEvent.on(a,'mousemove',d.DomEvent.stopPropagation),this._map.dragging.disable()},destroy:function(){this.stage.clearCache(),this.stage.clear()}}),a.prototype=c.merge(a.prototype,require('./leaflet_layer_konva.editor')),module.exports=a
function a(b,d){b.content.style.zIndex=1e3,this.options=c.deepMerge(a.options,d),this.stage=b}var b=require('bcore/event'),c=require('bcore/utils'),d=require('./../leaflet');a.options={transition:'opacity 0.4s',blending:'lighter',lazyFresh:!0,ptNPerLayer:1e3},a=b.extend(a,{beginDraw:function(){this.versionID=Math.random()},endDraw:function(){var a=this.shapes;for(var b in a){var c=a[b];c.__versionID!==this.versionID&&(c.destroy(),delete a[b])}this.lazyFresh()},clean:function(){var a=this.shapes;for(var b in a){var c=a[b];c.destroy(),delete a[b]}},cleanOld:function(){var c=this.versionID,b=this.cache,d,a,f;if(!(c&&b))return;for(var e in b)d=b[e],f=d.versionID,f!==c&&(a=d.visual,a&&(a.off&&a.off(),a.destroy&&a.destroy()),delete b[e])},addTo:function(a){this._map=a,this.resetVariables(),this.initEventsMap()},resetOffset:function(){this.pOffset=this.offset},disable:function(){this.isable=!1,this.stage.content.style.display='none'},enable:function(){this.isable=!0,this.stage.content.style.display='block'},resetVariables:function(){this.isable=!0,this.shapes={},this.layers=[],this.offset={x:0,y:0},this.pOffset={x:0,y:0}},add:function(a){this.stage.add(a)},addOrSetShape:function(b){var h=b.Constructor,i=b.index,e=b.attrs,f=b.data,c=b.id,a,d=this.shapes;if(d[c])return a=d[c],a.__options=b,a.__versionID=this.versionID,a.__data=f,d[c].setAttrs(e);var a=new h(e),g=this.getOrAddLayer(i);g.getCanvas().getContext('2d').globalCompositeOperation=this.options.blending,g.add(a),d[c]=a,a.__options=b,a.__versionID=this.versionID,a.__data=f},getOrAddLayer:function(b){if(!this.isable)return;b=Math.floor(b/this.options.ptNPerLayer);var c=this.layers,a=c[b];return a?a:(a=new Konva.Layer,c[b]=a,this.stage.add(a),a.canvas._canvas.style.zIndex=1e3-b,a)},fresh:function(){this.layers.forEach(function(a){a.draw()})},lazyFresh:function(){if(!this.isable)return;this.lazyFreshDraw(0)},lazyFreshDraw:function(b){var c=this;b=b||0;var a=this.layers[b];if(!a)return window.requestAnimationFrame(this.lazyFreshDone.bind(this));a.draw(),this.resetPos(a.canvas._canvas,{x:c.offset.x-c.pOffset.x,y:c.offset.y-c.pOffset.y}),a.canvas._canvas.style.opacity=1,a.canvas._canvas.style.transition=this.options.lazyFresh.transition,b++,this.lazyFreshId=window.requestAnimationFrame(function(){this.lazyFreshDraw(b)}.bind(this))},lazyFreshDone:function(){this.resetPos(this.stage.content),this.layers.forEach(function(a){d.DomUtil.setPosition(a.canvas._canvas,{x:0,y:0})})},resetPos:function(b,a){if(a=a||d.DomUtil.getPosition(this._map.getPanes().mapPane),!a)return;d.DomUtil.setPosition(b,{x:-a.x,y:-a.y})},stopLazyFresh:function(){if(!this.lazyFreshId)return;window.cancelAnimationFrame(this.lazyFreshId),this.lazyFreshId=null},hideLayers:function(){this.layers.forEach(function(a){a.canvas._canvas.style.opacity=0})},updateOptions:function(a){this.options=c.deepMerge(this.options,a),this.updateBlending()},updateBlending:function(b){var a=this.options;this.layers.forEach(function(b){b.getCanvas().getContext('2d').globalCompositeOperation=a.blending})},initEventsMap:function(){var a=this,b=this._map;b.on('zoomstart',function(){a.hideLayers(),a.stopLazyFresh()}).on('movestart',function(){a.stopLazyFresh()}).on('moveend',function(){a.pOffset=a.offset,a.offset=d.DomUtil.getPosition(b.getPanes().mapPane)}).on('resize',function(){console.log('resize')})},onKonva:function(a,b){return this.stage.on(a,b),this},enableMapEvents:function(){var a=this.stage.content;d.DomEvent.off(a,'click',d.DomEvent._fakeStop),d.DomEvent.off(a,'mousedown',d.DomEvent.stopPropagation),d.DomEvent.off(a,'mousemove',d.DomEvent.stopPropagation),this._map.dragging.enable()},disableMapEvents:function(){var a=this.stage.content;d.DomEvent.on(a,'click',d.DomEvent._fakeStop),d.DomEvent.on(a,'mousedown',d.DomEvent.stopPropagation),d.DomEvent.on(a,'mousemove',d.DomEvent.stopPropagation),this._map.dragging.disable()},destroy:function(){this.stage.clearCache(),this.stage.clear()}}),a.prototype=c.merge(a.prototype,require('./leaflet_layer_konva.editor')),module.exports=a
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