Comparing version 0.0.68 to 0.0.70
@@ -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('bcore/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,c=this.genStyle(a.style),d=this.geojson,e=a.geoid.bind(a),f=this.layers=[],g=this,h=this.geojsonLayer=b.geoJson(d,{style:c,onEachFeature:function(a,b){var c=e(a);f[c]=b,g.initEventChild(b,a)}});h.addTo(this._map)},initEventChild:function(a,e){var b={feature:e,layer:a},c=this,f,d=this.options.popup,g=this._map,h=['mouseover','click','mouseout','mousedown'];h.forEach(function(d){a.on(d,function(){a.__data&&(b.data=a.__data),c.fire('child-'+b,b)})}),a.on('mousedown',function(i){var d=a.__data;if(b){var h=c.getTopLatlng(a);f=b(d,e),g.openPopup(f,h)}})},getTopLatlng:function(c){var b=c._latlngs,a;return b.forEach(function(b){a||(a=b),b.lat>a.lat&&(a=b)}),a},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(c){this._data=c;var e=this.options.value,f,b,g,h,a=this.range=[];for(var i in c){if(f=c[i],b=e(f),d(b))continue;d(a[0])&&(a[0]=a[1]=b),g=a[0],h=a[1],b>h&&(a[1]=b),b<g&&(a[0]=b)}},render:function(a){a&&this.data(a),this.draw()},draw:function(){var d=this._data,a=this.options,i=a.style,l=a.id.bind(a),f=a.value.bind(a),c,h,b,j,k=this.layers,e=this.range;for(var g in d)c=d[g],j=f(c),h=l(c),b=k[h],b&&b.setStyle(this.genStyle(i,j,e[0],e[1])),b&&(b.__data=c)},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},popup:function(a,b){return a.properties.name}};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.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,onEachFeature:function(a,b){var c=f(a);g[c]=b,h.initEventChild(b,a)}});c.addTo(this._map),c.bringToBack()},initEventChild:function(a,b){var d={feature:b,layer:a},f=this,g,e=this.options.popup,h=this._map,i=['mouseover','click','mouseout','mousedown'];i.forEach(function(b){a.on(b,function(){a.__data&&(d.data=a.__data),f.fire('child-'+b,d)})}),a.on('mousedown',function(i){var f=a.__data;if(e){var d=c.getTopPoint(b);g=e(f,b),h.openPopup(g,[d[1],d[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(c){this._data=c;var e=this.options.value,f,b,g,h,a=this.range=[];for(var i in c){if(f=c[i],b=e(f),d(b))continue;d(a[0])&&(a[0]=a[1]=b),g=a[0],h=a[1],b>h&&(a[1]=b),b<g&&(a[0]=b)}},render:function(a){a&&this.data(a),this.draw()},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a),this.draw()},draw:function(){var d=this._data,a=this.options,i=a.style,l=a.id.bind(a),f=a.value.bind(a),c,h,b,j,k=this.layers,e=this.range;for(var g in d)c=d[g],j=f(c),h=l(c),b=k[h],b&&b.setStyle(this.genStyle(i,j,e[0],e[1])),b&&(b.__data=c)},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},popup:function(b,a){return a.adcode}};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(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 d=this,b=this.options.hoverScale||1,a,c=this.kLeafLayer.onKonva('dragstart',function(a){}).onKonva('mouseover touchstart',function(c){a=c.target,a.setAttrs({scale:{x:b,y:b}}),a.parent.draw()}).onKonva('mouseout',function(b){a=b.target,a.setAttrs({scale:{x:1,y:1}}),a.parent.draw()}).onKonva('mouseout mouseup touchend',function(a){setTimeout(function(){c.enableMapEvents()})}).onKonva('mousedown touchstart',this.onMouseDown.bind(this)),e=['mouseout','mousedown','mouseover','mouseout','touchstart','touchend','touchup'];e.forEach(function(a){c.onKonva(a,function(b){h(a,b,d)})})},onMouseDown:function(g){var c=this.options,d=this._map,e=g.target,f=e.__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(){var a=g.getClientRect(),d=a.x+a.width/2,e=a.y,c=f.containerPointToLatLng(b.point(d,e));f.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),this.initEditor()},data:function(c){this._data=c;var a=this.options,b=a.zIndex||a.child.zIndex;b&&(this._data=d.sortBy(c,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(e,n){if(!this.isable)return;var d=this.options,i=d.lat.bind(d),l=d.lng.bind(d),k=a(d.id.bind(d),e),f=a(d.size,e)||1,m=i(e),j=l(e),h=this._map.latLngToContainerPoint(b.latLng(m,j));return{data:e,Constructor:c.Image,index:n,id:k,attrs:{x:h.x,y:h.y,offset:{x:f/2,y:f/2},image:g(d.sprite||d.child.sprite,e),width:f,height:f,draggable:!1}}},draw:function(){var b=this._data;if(!b)return;if(!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()},initEditor:function(){this.eidtList=[],this.kLeafLayer.initEditor(),this.initEventEditor()},enableEditor:function(){this.kLeafLayer.enableEditor()},disableEditor:function(){this.kLeafLayer.disableEditor()},initEventEditor:function(){var a=this;this.kLeafLayer.on('shape-dragged',function(b){a.onShapeDragged(b.shape)})},onShapeDragged:function(e){var a=e.getClientRect(),f=a.x+a.width/2,g=a.y+a.height/2,h=this._map.containerPointToLatLng(b.point(f,g)),i=this.options,d=i.editor.setLatLng;if(!d)return console.log('请设置options.editor.setLatLng');var c=e.__data;d(h,c),this.kLeafLayer.addOrSetShape(c,null,!0),this.eidtList.push(c),this.fire('data-edited',c)},isEdited:function(){return this.eidtList.length>0},submitEdit:function(){var a=this.options,b=this.eidtList}});i.options={lng:f.getLng,lat:f.getLat,refreshInterval:1,ptNPerLayer:1e3,lazyFresh:{transition:'opacity 0.4s'},size:function(a){return 40},id:function(a,b){return a.id||b},hoverScale:1.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:{},editor:{setLatLng:function(b,a){if(!a)return;a.lat=b.lat,a.lng=b.lng}}};var j=b.dmap=b.dmap||{};j.ScatterKonva=i,j.scatterKonva=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 d=this,b=this.options.hoverScale||1,a,c=this.kLeafLayer.onKonva('dragstart',function(a){}).onKonva('mouseover touchstart',function(c){a=c.target,a.setAttrs({scale:{x:b,y:b}}),a.parent.draw()}).onKonva('mouseout',function(b){a=b.target,a.setAttrs({scale:{x:1,y:1}}),a.parent.draw()}).onKonva('mouseout mouseup touchend',function(a){setTimeout(function(){c.enableMapEvents()})}).onKonva('mousedown touchstart',this.onMouseDown.bind(this)),e=['mouseout','mousedown','mouseover','mouseout','touchstart','touchend','touchup'];e.forEach(function(a){c.onKonva(a,function(b){h(a,b,d)})})},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(f){var a=f.getClientRect(),d=a.x+a.width/2,e=a.y,c=g.containerPointToLatLng(b.point(d,e));g.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),this.initEditor()},data:function(c){this._data=c;var a=this.options,b=a.zIndex||a.child.zIndex;b&&(this._data=d.sortBy(c,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(e,n){if(!this.isable)return;var d=this.options,i=d.lat.bind(d),l=d.lng.bind(d),k=a(d.id.bind(d),e),f=a(d.size,e)||1,m=i(e),j=l(e),h=this._map.latLngToContainerPoint(b.latLng(m,j));return{data:e,Constructor:c.Image,index:n,id:k,attrs:{x:h.x,y:h.y,offset:{x:f/2,y:f/2},image:g(d.sprite||d.child.sprite,e),width:f,height:f,draggable:!1}}},draw:function(){var b=this._data;if(!b)return;if(!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()},initEditor:function(){this.eidtList=[],this.kLeafLayer.initEditor(),this.initEventEditor()},enableEditor:function(){this.kLeafLayer.enableEditor()},disableEditor:function(){this.kLeafLayer.disableEditor()},initEventEditor:function(){var a=this;this.kLeafLayer.on('shape-dragged',function(b){a.onShapeDragged(b.shape)})},onShapeDragged:function(e){var a=e.getClientRect(),f=a.x+a.width/2,g=a.y+a.height/2,h=this._map.containerPointToLatLng(b.point(f,g)),i=this.options,d=i.editor.setLatLng;if(!d)return console.log('请设置options.editor.setLatLng');var c=e.__data;d(h,c),this.kLeafLayer.addOrSetShape(c,null,!0),this.eidtList.push(c),this.fire('data-edited',c)},isEdited:function(){return this.eidtList.length>0},submitEdit:function(){var a=this.options,b=this.eidtList}});i.options={lng:f.getLng,lat:f.getLat,refreshInterval:1,ptNPerLayer:1e3,lazyFresh:{transition:'opacity 0.4s'},size:function(a){return 40},id:function(a,b){return a.id||b},hoverScale:1.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:{},editor:{setLatLng:function(b,a){if(!a)return;a.lat=b.lat,a.lng=b.lng}}};var j=b.dmap=b.dmap||{};j.ScatterKonva=i,j.scatterKonva=function(a){return new i(a)},module.exports=i |
@@ -5,3 +5,3 @@ { | ||
"description": "2d map visualization lib", | ||
"version": "0.0.68", | ||
"version": "0.0.70", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
314614