Comparing version 0.0.84 to 0.0.85
@@ -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=c.EVENTS,e=require('bcore/event'),f=require('./scatter_marker'),g=b.dmap=b.dmap||{};a.options={lat:c.getLat,lng:c.getLng,filter:function(a,b){return!0},popupText:'loading...',range:[0,1],id:function(a,b){return a.id||b},text:function(a){return a.text},value:function(a){return a.value||a.num||a[0]},zoom:{max:15,min:3},child:{size:function(a,b,c){return 15},shape:{normal:{}}}},a=e.extend(a,{initialize:function(a){this.cache={},this.isable=!0},addTo:function(a){if(!a)return;this._map=a,this.initEventsMap(),this.initPopUp()},initPopUp:function(){var a=this._map;a||(a._popup=b.popup('...'))},data:function(a){this._data=a},clean:function(){var a=this.cache,c,b;if(!a)return;for(var d in a)c=a[d],b=c.visual,b&&b.destroy&&(b.destroy(),delete c.visual)},updateData:function(a){this.processing(a),this.cleanOld()},updateFilter:function(a){if(typeof a!=='function')return;this.options.filter=a,this.updateMap()},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])},processing:function(y){var t=this.versionID=Math.random(),j=this._map;if(!j)return;var c=this.options,w=this.getChildOptions(),a,i,u,v,d,b,n=this.isInZoom(),o=this._map.getZoom(),p=c.id,q=c.lat,r=c.lng,s=c.filter,g=c.groups,k,h,l=this.cache,m=this.isable;for(var e in y){if(a=y[e],c.processing&&c.processing(a),i=p(a,e),u=q(a),v=r(a),d=l[i],k=!0,k=s(a,o),h=!0,g){h=!1;for(var e in g){var x=g[e];if(x.filter(a)){h=!0;break}}}if(d?d.data=a:d=l[i]={data:a},d.versionID=t,n&&k&&h&&this.isInView(u,v)&&m){var b=d.visual;b?b.updateData(a):m&&(b=d.visual=new f(w),b.addTo(j),b.render(a),this.initEventsScatter(b))}}this.updateRange()},render:function(a){a&&this.data(a),a=this._data,this.updateData(a)},enable:function(){this.isable=!0},disable:function(){this.isable=!1},isInZoom:function(){var a=this.options.zoom;if(!a)return!0;var c=this._map,d=a.max,e=a.min,b=c.getZoom();return b>d||b<e?!1:!0},isInView:function(b,c,a){a=a||this._map.getBounds();var d=a._northEast.lng,e=a._northEast.lat,f=a._southWest.lng,g=a._southWest.lat;return b<e&&b>g&&c<d&&c>f},each:function(c){var a=this.cache;for(var b in a)c(a[b])},getOptionsValue:function(b){var a=this.options;return a.child[b]||a[b]},getChildOptions:function(){var a={};return['id','text','lat','lng','range','value','css','popupText'].forEach(function(b){a[b]=this.getOptionsValue(b)}.bind(this)),a},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a);var b,d=this.getChildOptions(),e=a.popup;this.each(function(c){var a=c.visual;a&&(a.updateOptions(d),b=a.popupGroup,b&&b.updateOptions(e))}),this.draw()},draw:function(){var e=this.options,g=this.cache,d,a,l,h,b,j=e.lng,k=e.lat,c,m,n=e.filter,o=this._map.getZoom(),p,q=this.isInZoom(),t=e.groups;if(!q)return this.clean();if(!g)return;if(!this.isable)return;var s=this.getChildOptions(),r=this._map;for(var i in g)d=g[i],b=d.data,l=k(b),h=j(b),p=this.isInView(l,h),c=!0,c=n(b,o),m=!0,c=c&&m,a=d.visual,p&&c?a?(a.updateData(b),a.updateZIndex()):(a=d.visual=new f(s),a.addTo(r),a.render(b),this.initEventsScatter(a)):a&&(a.off&&a.off(),a.destroy&&a.destroy(),delete d.visual)},updateMap:function(){this.draw()},updateRange:function(){var c=this.cache,d=this.ranges=this.ranges||{},e=this.options.value,a=d.value=[];for(var f in c){var g=c[f].data,b=e(g);a[0]||(a=[b,b]),b<a[0]&&(a[0]=b),b>a[1]&&(a[1]=b)}},initEventsPopup:function(a){var b=this._map;c.initEventsPopup(this,a,b,a._data,this.options.popup),b.on('zoomend',function(){a.updatePopupPostion()}.bind(this))},initEventsMap:function(){this._map.on('moveend',this.updateMap.bind(this))},initEventsScatter:function(a){var b=this;d.forEach(function(c){a.on(c,function(a){b.emit('child-'+c,a)})}),this.initEventsPopup(a)},destroy:function(){this.clean(),this.cache={}}}),g.ScatterMarkers=a,g.scatterMarkers=function(b){return new a(b)},module.exports=a | ||
function a(b){b=this.options=c.deepMerge(a.options,b),this.getChildOptions(),this.initialize(b)}var b=require('leaflet'),c=require('./../core/utils'),d=c.EVENTS,e=require('bcore/event'),f=require('./scatter_marker'),g=b.dmap=b.dmap||{};a.options={lat:c.getLat,lng:c.getLng,filter:function(a,b){return!0},popupText:'loading...',range:[0,1],id:function(a,b){return a.id||b},text:function(a){return a.text},value:function(a){return a.value||a.num||a[0]},zoom:{max:15,min:3},child:{size:function(a,b,c){return 15},shape:{normal:{}}}},a=e.extend(a,{initialize:function(a){this.cache={},this.isable=!0},addTo:function(a){if(!a)return;this._map=a,this.initEventsMap(),this.initPopUp()},initPopUp:function(){var a=this._map;a||(a._popup=b.popup('...'))},data:function(a){this._data=a},clean:function(){var a=this.cache,c,b;if(!a)return;for(var d in a)c=a[d],b=c.visual,b&&b.destroy&&(b.destroy(),delete c.visual)},updateData:function(a){this.processing(a),this.cleanOld()},updateFilter:function(a){if(typeof a!=='function')return;this.options.filter=a,this.updateMap()},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])},processing:function(y){var t=this.versionID=Math.random(),j=this._map;if(!j)return;var c=this.options,w=this.getChildOptions(),a,i,u,v,d,b,n=this.isInZoom(),o=this._map.getZoom(),p=c.id,q=c.lat,r=c.lng,s=c.filter,g=c.groups,k,h,l=this.cache,m=this.isable;for(var e in y){if(a=y[e],c.processing&&c.processing(a),i=p(a,e),u=q(a),v=r(a),d=l[i],k=!0,k=s(a,o),h=!0,g){h=!1;for(var e in g){var x=g[e];if(x.filter(a)){h=!0;break}}}if(d?d.data=a:d=l[i]={data:a},d.versionID=t,n&&k&&h&&this.isInView(u,v)&&m){var b=d.visual;b?b.updateData(a):m&&(b=d.visual=new f(w),b.addTo(j),b.render(a),this.initEventsScatter(b))}}this.updateRange()},render:function(a){a&&this.data(a),a=this._data,this.updateData(a)},enable:function(){this.isable=!0},disable:function(){this.isable=!1},isInZoom:function(){var a=this.options.zoom;if(!a)return!0;var c=this._map,d=a.max,e=a.min,b=c.getZoom();return b>d||b<e?!1:!0},isInView:function(b,c,a){a=a||this._map.getBounds();var d=a._northEast.lng,e=a._northEast.lat,f=a._southWest.lng,g=a._southWest.lat;return b<e&&b>g&&c<d&&c>f},each:function(c){var a=this.cache;for(var b in a)c(a[b])},getOptionsValue:function(b){var a=this.options;return a.child[b]||a[b]},getChildOptions:function(){var a={},b=this;return['id','text','lat','lng','range','value','css','popupText','popup'].forEach(function(c){a[c]=b.options[c]=this.getOptionsValue(c)}.bind(this)),a},updateOptions:function(a){a=this.options=c.deepMerge(this.options,a);var b,d=this.getChildOptions(),e=a.popup;this.each(function(c){var a=c.visual;a&&(a.updateOptions(d),b=a.popupGroup,b&&b.updateOptions(e))}),this.draw()},draw:function(){var e=this.options,g=this.cache,d,a,l,h,b,j=e.lng,k=e.lat,c,m,n=e.filter,o=this._map.getZoom(),p,q=this.isInZoom(),t=e.groups;if(!q)return this.clean();if(!g)return;if(!this.isable)return;var s=this.getChildOptions(),r=this._map;for(var i in g)d=g[i],b=d.data,l=k(b),h=j(b),p=this.isInView(l,h),c=!0,c=n(b,o),m=!0,c=c&&m,a=d.visual,p&&c?a?(a.updateData(b),a.updateZIndex()):(a=d.visual=new f(s),a.addTo(r),a.render(b),this.initEventsScatter(a)):a&&(a.off&&a.off(),a.destroy&&a.destroy(),delete d.visual)},updateMap:function(){this.draw()},updateRange:function(){var c=this.cache,d=this.ranges=this.ranges||{},e=this.options.value,a=d.value=[];for(var f in c){var g=c[f].data,b=e(g);a[0]||(a=[b,b]),b<a[0]&&(a[0]=b),b>a[1]&&(a[1]=b)}},initEventsPopup:function(a){var b=this._map;c.initEventsPopup(this,a,b,a._data,this.options.popup),b.on('zoomend',function(){a.updatePopupPostion()}.bind(this))},initEventsMap:function(){this._map.on('moveend',this.updateMap.bind(this))},initEventsScatter:function(a){var b=this;d.forEach(function(c){a.on(c,function(a){b.emit('child-'+c,a)})}),this.initEventsPopup(a)},destroy:function(){this.clean(),this.cache={}}}),g.ScatterMarkers=a,g.scatterMarkers=function(b){return new a(b)},module.exports=a |
@@ -5,3 +5,3 @@ { | ||
"description": "2d map visualization lib", | ||
"version": "0.0.84", | ||
"version": "0.0.85", | ||
"scripts": { | ||
@@ -8,0 +8,0 @@ "test": "mocha -r jscoverage test" |
@@ -1,1 +0,1 @@ | ||
'use strict';function a(c,b){this.container=f.getContainer(c),b=arguments[arguments.length-1],this.options=f.deepMerge(a.options,b)}function b(c,d){var b;for(var a=0;a<c.length;a++){if(b=c[a],!b.style)continue;d(b)}}function c(a,b){return b=b||10,typeof a==='number'&&(a=a.toString()),a.length>b?a.substring(0,b):a}function d(a,b,d,e,f){return a=c(a,f),b=c(b,e),'<div class="leaflet-popup-line" id="'+d+'"> <div class="leaflet-popup-name">'+b+': </div> <a href="#'+a+'" class="leaflet-popup-value">'+a+'</a> </div>'}var e=require('./../leaflet'),f=require('bcore/utils'),g=require('bcore/event');require('./popup.css'),a.options={type:'list',colorValue:'#00ffe1',colorLine:'rgba(0,0,0,0.2)',colorKey:'#938c8c',background:'rgba(20,20,20,0.4)',limitName:8,limitValue:15},a=g.extend(a,{bindTo:function(a){},updateStyle:function(){var a=this.options,c=this.container,d=c.parentNode,e=d.nextSibling.getElementsByClassName('leaflet-popup-tip')[0];d.style.background=e.style.background=a.background,b(c.getElementsByClassName('leaflet-popup-line'),function(b){b.style.color=a.colorKey}),b(c.getElementsByClassName('leaflet-popup-name'),function(b){b.style.color=a.colorKey}),b(c.getElementsByClassName('leaflet-popup-value'),function(b){b.style.color=a.colorValue})},data:function(a){this._data=a},render:function(a){a&&this.data(a),this.draw(),this.updateStyle(),this.initEvents()},getIncludeDefault:function(b){var b,a=[];for(var c in b)a.push({key:c});return a},draw:function(){var a=this._data,c=this,d=this.options.include||this.getIncludeDefault(a),b='';d.forEach(function(f){var d=f.key,g=f.name||d,e=a[d];e&&(b+=c.getHTML(e,g,d))}),this.container.style.width='auto',this.container.innerHTML=b},getHTML:function(c,e,f){var a=this.options,b=this.options.type||'list';return b==='list'?d(c,e,f,a.limitName,a.limitValue):void 0},initEvents:function(){var c=this.container.getElementsByClassName('leaflet-popup-line'),a=this,d=['click'];d.forEach(function(d){b(c,function(b){b.addEventListener(d,function(){var c=b.getAttribute('id');a.emit(d,{id:c,data:a._data,layer:a})})})})},updateOptions:function(a){this.options=f.deepMerge(this.options,a),this.updateStyle()}});var h=e.dmap=e.dmap||{};h.Popup=a,h.popup=function(b){return a(b)},module.exports=a | ||
'use strict';function a(c,b){this.container=g.getContainer(c),b=arguments[arguments.length-1],this.options=g.deepMerge(a.options,b)}function b(c,d){var b;for(var a=0;a<c.length;a++){if(b=c[a],!b.style)continue;d(b)}}function c(a,b){return b=b||10,typeof a==='number'&&(a=a.toString()),a.length>b?a.substring(0,b):a}function d(a,b,d,e,f){return a=c(a,f),b=c(b,e),'<div class="leaflet-popup-line" id="'+d+'"> <div class="leaflet-popup-name">'+b+': </div> <a href="#'+a+'" class="leaflet-popup-value">'+a+'</a> </div>'}function e(a,b,d,e,f){return a=c(a,f),b=c(b,e),'<div class="leaflet-popup-line" id="'+d+'"> <div class="leaflet-popup-name">'+b+': </div> <input placeholder="'+a+'" class="leaflet-popup-value" value="'+a+'"></input> </div>'}var f=require('./../leaflet'),g=require('bcore/utils'),h=require('bcore/event');require('./popup.css'),a.options={type:'list',colorValue:'#00ffe1',colorLine:'rgba(0,0,0,0.2)',colorKey:'#938c8c',background:'rgba(20,20,20,0.4)',limitName:8,limitValue:15},a=h.extend(a,{bindTo:function(a){},updateStyle:function(){var a=this.options,c=this.container,d=c.parentNode,e=d.nextSibling.getElementsByClassName('leaflet-popup-tip')[0];d.style.background=e.style.background=a.background,b(c.getElementsByClassName('leaflet-popup-line'),function(b){b.style.color=a.colorKey}),b(c.getElementsByClassName('leaflet-popup-name'),function(b){b.style.color=a.colorKey}),b(c.getElementsByClassName('leaflet-popup-value'),function(b){b.style.color=a.colorValue})},data:function(a){this._data=a},render:function(a){a&&this.data(a),this.draw(),this.updateStyle(),this.initEvents()},getIncludeDefault:function(b){var b,a=[];for(var c in b)a.push({key:c});return a},draw:function(){var a=this._data,c=this,d=this.options.include||this.getIncludeDefault(a),b='';d.forEach(function(f){var d=f.key,g=f.name||d,e=a[d];e&&(b+=c.getHTML(e,g,d))}),this.container.style.width='auto',this.container.innerHTML=b},getHTML:function(b,c,f){var a=this.options,g=this.options.type||'list';if(g==='record')return d(b,c,f,a.limitName,a.limitValue);if(g==='input')return e(b,c,f,a.limitName,a.limitValue);if(g==='list')return a.getLineHtml(b,c,f,a.limitName,a.limitValue);d(b,c,f,a.limitName,a.limitValue)},initEvents:function(){var a=this.options.type||'list';if(a==='record')return this.initEventsLine();if(a==='input')return this.initEventsInput();if(a==='list')return this.initEventsLine();this.initEventsLine()},initEventsLine:function(){var c=this.container.getElementsByClassName('leaflet-popup-line'),a=this,d=['click'];d.forEach(function(d){b(c,function(b){b.addEventListener(d,function(){var c=b.getAttribute('id');a.emit(d,{id:c,data:a._data,layer:a})})})})},initEventsInput:function(){},updateOptions:function(a){this.options=g.deepMerge(this.options,a),this.updateStyle()}});var i=f.dmap=f.dmap||{};i.Popup=a,i.popup=function(b){return a(b)},module.exports=a |
Sorry, the diff of this file is not supported yet
320279
949