-
Notifications
You must be signed in to change notification settings - Fork 2
/
dataninja-advanced-mapping-tool.min.js
3 lines (3 loc) · 47.7 KB
/
dataninja-advanced-mapping-tool.min.js
1
2
3
/*! dataninja-advanced-mapping-tool 12-12-2014 */
mapConfig&&(mapConfig.dataSources={shape:{},file:{domain:"",path:"",filename:"",format:"",url:function(a,b,c){return this.domain+this.path+(this.filename||a+(b&&c?"_"+b+"-"+c:"")+"."+this.format)},transform:function(a){return a}},dkan:{domain:"",path:"",resourceId:"",limit:5e3,format:"json",url:function(a,b,c){return this.domain+this.path+"?resource_id="+this.resourceId+(b&&c?"&filters["+b+"]="+c:"")+(this.limit?"&limit="+this.limit:"")},transform:function(a){return a.result.records}}}),mapConfig&&(mapConfig.dataTypes={choropleth:{palette:"Reds",precision:0,bins:3},points:{}}),mapConfig&&(mapConfig.geoSources={file:{domain:"",path:"",format:"geojson",filename:"",url:function(a,b,c){return this.domain+this.path+(this.filename||a+(b&&c?"_"+b+"-"+c:"")+"."+this.format)},transform:function(a){return a}},tileserver:{domain:"http://{s}.tile.openstreetmap.org",path:"/{z}/{x}/{y}.png",url:function(){return this.domain+this.path}}}),mapConfig&&(mapConfig.geoTypes={tile:{active:!0,source:"tileserver",options:{attribution:"",opacity:.7}},thematic:{active:!0,classification:"Jenks",infowindow:!0,tooltip:!0,zoom:0,style:{"default":{weight:.5,opacity:1,color:"white",fillOpacity:.7,fillColor:"none"},highlight:{},selected:{weight:2,color:"#666"}}}}),mapConfig&&(mapConfig.viewTypes={table:function(a,b,c,d){if(!a)return"";mapConfig.debug&&console.log("views",arguments);var e,f={include:[],exclude:[],bold:function(){return!1},filter:function(){return!0}},b=b||{},g="",h="",i=0;_.defaults(b,f),b.groups=d||{},b.formatter=c||function(a,b){return _.isNumber(b)?d3.format(",d")(b)||d3.format(",.2f")(b):b};for(e in a)if(_.has(a,e)&&!(b.include.length&&!_.contains(b.include,e)||b.exclude.length&&_.contains(b.exclude,e)||!b.filter(e,a[e]))){var j=b.formatter(e,a[e]),k=b.bold(e,a[e]),l=_.has(b.groups,e);l&&b.groups[e]!=g&&(i++,g=b.groups[e],h+='<tr class="first-level group g'+i+'"><td colspan="2"><span>'+g+"</span></td></tr>"),h+='<tr class="'+(l?"second-level hidden g"+i:"first-level")+'"><td class="table-key"><span>'+(k?"<b>"+e+"</b>":e)+'</span></td><td class="table-value"><span>'+(k?"<b>"+j+"</b>":j)+"</span></td></tr>"}return h}}),function(a){if(console.log("mapConfig",mapConfig),!a)throw"ERRORE: configurazione errata o mancante...";d3.geojson=d3.topojson=d3.json,head.ready(function(){function a(a,b,c){for(var d=c.replace("~",""),e=colorbrewer[d][b.length-1]?b.length-1:3,f="~"===c[0]?_.clone(colorbrewer[d][e]).reverse():colorbrewer[d][e],g=1;g<b.length;g++)if(a<=b[g])return f[g-1]}function b(b){var c=b.properties._layer,d=n.geoLayers.filter(function(a){return"thematic"===a.type&&a.schema.name===c})[0],e=t[c].filter(function(a){return a.active})[0],f=_.clone(d.style.default);return b._selected&&_.extend(f,d.style.selected),f.fillColor=_.has(b.properties._data,e.name)?a(b.properties._data[e.name][e.column],e.bins,e.palette):"transparent",f}function c(a){var b=a.target,c=b.feature.properties,d=b.feature.properties._layer,e=n.geoLayers.filter(function(a){return"thematic"===a.type&&a.schema.name===d})[0],f=t[d].filter(function(a){return a.active})[0],g=e.style.highlight,h=c._data[f.name][f.column];b.feature._selected||b.setStyle(g),_.has(n,"tooltip")&&n.tooltip.active&&(!_.has(e,"tooltip")||e.tooltip)&&(db.setContent((r[d].label?c[r[d].label]+"<br>":"")+f.label+": "+f.formatter(f.column,h)),db.setLatLng(b.getBounds().getCenter()),y.showLabel(db))}function d(a){{var b=a.target,c=b.feature.properties._layer,d=n.geoLayers.filter(function(a){return"thematic"===a.type&&a.schema.name===c})[0];d.style.default}b.feature._selected||cb.resetStyle(b),_.has(n,"tooltip")&&n.tooltip.active&&db.close()}function e(a,b){n.debug&&console.log("openInfoWindowFunction",arguments);var b=b||a.target,c=b.feature.properties._layer,d=n.geoLayers.filter(function(a){return"thematic"===a.type&&a.schema.name===c})[0],e=d.style.selected;_.has(d,"infowindow")&&d.infowindow&&(b.feature._selected||(m&&(m.feature._selected=!1,cb.resetStyle(m)),b.feature._selected=!0,b.feature._position=_.indexOf(_.keys(cb._layers),""+b._leaflet_id),b.setStyle(e),w.i=b.feature.properties[r[w.dl].id],P&&P.isAdded&&P.removeFrom(y),H.update(b.feature.properties)),L.Browser.ie||L.Browser.opera||b.bringToFront(),m=b)}function f(a,b){b.on({mouseover:c,mouseout:d,click:e})}function g(a){n.debug&&console.log("joinDataFunction",arguments);for(var b,c,d=0;d<r[a].resource.length;d++){b=r[a].resource[d].properties[r[a].id],r[a].resource[d].properties._data={};for(var e=0;e<t[a].length;e++)if(t[a][e].active=!e,t[a][e].id)for(var f=0;f<t[a][e].resource.length;f++){var c=t[a][e].resource[f][t[a][e].id];if(c==b){r[a].resource[d].properties._data[t[a][e].name]=t[a][e].resource[f];for(var g in r[a].resource[d].properties._data[t[a][e].name])_.has(r[a].resource[d].properties._data[t[a][e].name],g)&&(r[a].resource[d].properties._data[t[a][e].name][g]=t[a][e].parse(g,r[a].resource[d].properties._data[t[a][e].name][g]));r[a].resource[d].properties._layer=a}}else{t[a][e].resource.push(_.clone(r[a].resource[d].properties)),r[a].resource[d].properties._data[t[a][e].name]=t[a][e].resource[d];for(var g in r[a].resource[d].properties._data[t[a][e].name])_.has(r[a].resource[d].properties._data[t[a][e].name],g)&&(r[a].resource[d].properties._data[t[a][e].name][g]=t[a][e].parse(g,r[a].resource[d].properties._data[t[a][e].name][g]));r[a].resource[d].properties._layer=a}d3.keys(r[a].resource[d].properties._data).length||(r[a].resource.splice(d,1),d--)}}function h(a){n.debug&&console.log("binDataFunction",arguments);var b,c,d=t[a].filter(function(a){return a.active})[0],e=n.geoLayers.filter(function(b){return"thematic"===b.type&&b.schema.name===a})[0],f=d.resource.map(function(a){return a[d.column]}),g=new geostats(f);if(f.length>3?d.binsNum>f.length&&(d.binsNum=f.length-1):d.binsNum=3,_.isArray(e.classification))d.binsNum=e.classification.length-1,b=g.setClassManually(_.flatten([d3.min(f),e.classification.slice(1,-1),d3.max(f)])).map(function(a){return parseFloat(a)||a}),c=g.ranges,c[0]=e.classification[0]+" - "+c[0].split(" - ")[1],c[c.length-1]=c[c.length-1].split(" - ")[0]+" - "+e.classification[e.classification.length-1];else{b=g["get"+e.classification](d.binsNum).map(function(a){return parseFloat(a)||a});var h=_.uniq(b);d.binsNum>3&&h.length<b.length&&(d.binsNum=h.length-1,b=g["get"+e.classification](d.binsNum).map(function(a){return parseFloat(a)||a})),c=g.ranges}if(d.precision){for(var i=1;i<b.length-1;i++)b[i]=Math.round(b[i]/d.precision)*d.precision;b=g.setClassManually(_.flatten([d3.min(f),b.slice(1,-1),d3.max(f)])).map(function(a){var b=parseFloat(a);return _.isNumber(b)&&!_.isNaN(b)?b:a}),c=g.ranges,c[0]=Math.floor(b[0]/d.precision)*d.precision+" - "+c[0].split(" - ")[1],c[c.length-1]=c[c.length-1].split(" - ")[0]+" - "+(Math.floor(b[b.length-1]/d.precision)+1)*d.precision}d.bins=b,d.ranges=c,V.update(a)}function i(a){n.debug&&console.log("loadDataFunction",arguments);var b,c,d,f=n.geoLayers.filter(function(b){return"thematic"===b.type&&b.schema.name===a})[0],i=n.dataSets.filter(function(b){return b.schema.layer===a});if(w.dl=a,cb&&cb.clearLayers(),n.debug&&console.log("geoLayer",f),n.debug&&console.log("dataSets",i),r[a].resource.length)h(a),cb.addData(r[a].resource),m&&(m=cb._layers[_.keys(cb._layers)[m.feature._position]],L.Browser.ie||L.Browser.opera||m.bringToFront()),delete w.i,P&&P.isAdded&&P.removeFrom(y),V.update(a);else{y.spin(!0),d=queue(),b=f.url.call(f,a,w.t?w.tl:void 0,w.t||void 0),d.defer(d3[f.format],b),n.debug&&console.log("geoPath",b);for(var k=0;k<i.length;k++)"shape"!=i[k].source&&(c=i[k].url.call(i[k],a,w.t?s[w.tl].id:void 0,w.t||void 0),d.defer(d3[i[k].format],c),n.debug&&console.log("dataPath",k,c));d.await(function(b,c){n.debug&&console.log("await",arguments),c=f.transform.call(f,c),"topojson"===f.format?r[a].resource=topojson.feature(c,c.objects[f.filename.split(".")[0]]).features:"geojson"===f.format&&(r[a].resource=c.features);for(var d=2;d<arguments.length;d++)t[a][d-2].resource=i[d-2].transform.call(i[d-2],arguments[d]);g(a),h(a),cb.addData(r[a].resource),y.spin(!1),j||(j=d3.select(".leaflet-overlay-pane svg").attr("viewBox").split(" ")),w.t&&y.fitBounds(cb.getBounds()),w.i&&cb.eachLayer(function(b){b.feature.properties[r[a].id]==w.i&&e(null,b)})})}}var j,k,l,m,n=mapConfig;if(_.has(n,"language")){var o;switch(n.language){case"it":o=d3.locale({decimal:",",thousands:".",grouping:[3],currency:["€ ",""],dateTime:"%a %b %e %X %Y",date:"%d/%m/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"],shortDays:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],months:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],shortMonths:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"]});break;default:o=d3.locale()}d3.format=o.numberFormat,d3.time.format=o.timeFormat}for(_.has(n,"analytics")&&n.analytics.active&&(!function(a,b,c,d,e,f,g){a.GoogleAnalyticsObject=e,a[e]=a[e]||function(){(a[e].q=a[e].q||[]).push(arguments)},a[e].l=1*new Date,f=b.createElement(c),g=b.getElementsByTagName(c)[0],f.async=1,f.src=d,g.parentNode.insertBefore(f,g)}(window,document,"script","//www.google-analytics.com/analytics.js","ga"),ga("create",n.analytics.ua||"","auto"),ga("send","pageview")),k=0;k<n.geoLayers.length;k++)_.has(n.geoTypes[n.geoLayers[k].type],"options")&&(n.geoLayers[k].options=n.geoLayers[k].options||{},_.defaults(n.geoLayers[k].options,n.geoTypes[n.geoLayers[k].type].options)),_.has(n.geoTypes[n.geoLayers[k].type],"style")&&(n.geoLayers[k].style=n.geoLayers[k].style||{"default":{},highlight:{},selected:{}},_.defaults(n.geoLayers[k].style.default,n.geoTypes[n.geoLayers[k].type].style.default),_.defaults(n.geoLayers[k].style.highlight,n.geoTypes[n.geoLayers[k].type].style.highlight),_.defaults(n.geoLayers[k].style.selected,n.geoTypes[n.geoLayers[k].type].style.selected)),_.defaults(n.geoLayers[k],n.geoTypes[n.geoLayers[k].type]),_.defaults(n.geoLayers[k],n.geoSources[n.geoLayers[k].source]);for(n.geoLayers=_.where(n.geoLayers,{active:!0}),k=0;k<n.dataSets.length;k++)_.defaults(n.dataSets[k],n.dataTypes[n.dataSets[k].type]),_.defaults(n.dataSets[k],n.dataSources[n.dataSets[k].source]);if(n.dataSets=_.filter(n.dataSets,function(a){return _.has(a,"schema")&&_.has(a.schema,"layer")&&_.contains(_.map(n.geoLayers,function(a){return _.has(a,"schema")?a.schema.name:void 0}),a.schema.layer)}),_.has(n,"infowindow")&&n.infowindow.active&&_.has(n.infowindow,"downloads")&&n.infowindow.downloads.active)for(k=0;k<n.infowindow.downloads.files.length;k++)n.infowindow.downloads.files[k].active&&_.defaults(n.infowindow.downloads.files[k],n.dataSources[n.infowindow.downloads.files[k].source]);_.has(n,"pointsSet")&&n.pointsSet.active&&_.defaults(n.pointsSet,n.dataSources[n.pointsSet.source]),n.debug&&console.log("$",n);var p;_.has(n,"urlShortener")&&n.urlShortener.active&&(p=yourls.connect(n.urlShortener.url.call(n.urlShortener),{signature:n.urlShortener.signature})),n.debug&&console.log("dtnj",p);var q={},r={};for(k=0;k<n.geoLayers.length;k++)"thematic"===n.geoLayers[k].type&&(q[n.geoLayers[k].schema.name]={id:n.geoLayers[k].schema.id,label:n.geoLayers[k].schema.label,resource:[],list:[]});n.debug&&console.log("defaultGeo",q);var s={},t={};for(k=0;k<n.dataSets.length;k++){var u=n.dataSets[k];if(s[u.schema.name]={name:u.schema.name||_.uniqueId("dataset-"),layer:u.schema.layer,id:"shape"!=u.source?u.schema.id||void 0:void 0,groups:{},columns:_.has(u.schema,"menu")&&u.schema.menu.length?u.schema.menu.map(function(a){return a.column}):null,labels:_.has(u.schema,"menu")&&u.schema.menu.length?u.schema.menu.map(function(a){return a.label||a.column}):null,descriptions:_.has(u.schema,"menu")&&u.schema.menu.length?u.schema.menu.map(function(a){return a.description||u.schema.description||(a.label?a.label+">"+a.column:a.column)}):null,precisions:_.has(u.schema,"menu")&&u.schema.menu.length?u.schema.menu.map(function(a){return _.isNumber(a.precision)?a.precision:u.precision||0}):null,resourceId:u.resourceId,palette:u.palette||"Reds",transform:u.transform||function(a,b){return b},resource:[],binsNums:_.has(u.schema,"menu")&&u.schema.menu.length?u.schema.menu.map(function(a){return a.bins||u.bins}):null,bins:[],ranges:[],active:!1},s[u.schema.name].menuLabel=u.schema.label||s[u.schema.name].name,s[u.schema.name].column=s[u.schema.name].columns[0],s[u.schema.name].label=s[u.schema.name].labels[0],s[u.schema.name].description=s[u.schema.name].descriptions[0],s[u.schema.name].precision=s[u.schema.name].precisions[0],s[u.schema.name].binsNum=s[u.schema.name].binsNums[0],_.has(u.schema,"groups")&&!_.isEmpty(u.schema.groups))for(l in u.schema.groups)_.has(u.schema.groups,l)&&!_.isEmpty(u.schema.groups[l])&&_.each(u.schema.groups[l],function(a){s[u.schema.name].groups[a]=l});if(_.isString(u.parse)){var v=window[u.parse];s[u.schema.name].parse=function(a,b){var c=v(b);return _.isNumber(c)&&!_.isNaN(c)?c:b}}else s[u.schema.name].parse=_.isFunction(u.parse)?u.parse:function(a,b){var c=parseFloat(b);return _.isNumber(c)&&!_.isNaN(c)?c:b};_.isString(u.formatter)&&!_.isEmpty(u.formatter)?s[u.schema.name].formatter=function(a,b){return d3.format(u.formatter)(b)}:_.isFunction(u.formatter)?!function(a){var b=n.dataSets[a];s[b.schema.name].formatter=function(a,c){var d=b.formatter(a,c);return d?d3.format(d)(c):_.isNumber(c)?d3.format(",d")(c)||d3.format(",.2f")(c):c}}(k):s[u.schema.name].formatter=function(a,b){return _.isNumber(b)?d3.format(",d")(b)||d3.format(",.2f")(b):b}}n.debug&&console.log("defaultData",s);var w=Arg.query();for(w.ls=w.ls||d3.keys(q),w.ml=w.ls[0],w.dl=w.dl||w.ml,w.md=w.md||(L.Browser.mobile&&head.screen.innerWidth<800?"widget":""),d3.select("body").classed(w.md,!0),w.t&&(w.tl=w.tl||w.ml,w.ml=w.ls[_.indexOf(w.ls,w.tl)+1],_.indexOf(w.ls,w.dl)<_.indexOf(w.ls,w.tl)+1&&(w.dl=w.ml)),_.has(n,"pointsSet")&&n.pointsSet.active&&w.mr&&_.has(w.mr,"rid")&&(n.pointsSet.resourceId=w.mr.rid,w.mr.lat=w.mr.lat||"lat",w.mr.lng=w.mr.lng||"lng"),_.has(n,"summary")&&!_.isUndefined(w.summary)&&(n.summary.closed=!w.summary),n.debug&&console.log("parameters",w),k=_.indexOf(w.ls,w.ml);k<w.ls.length;k++)if(_.has(q,w.ls[k])){var x=[];for(l in s)_.has(s,l)&&s[l].layer===w.ls[k]&&x.push(s[l]);x.length&&(r[w.ls[k]]=q[w.ls[k]],t[w.ls[k]]=_.each(x,function(a,b){a.index=b}))}n.debug&&console.log("geo",r),n.debug&&console.log("data",t);var y,z,A,B,C,D,E;_.has(n.map,"bounds")&&(_.has(n.map.bounds,"init")&&(z=L.latLng(n.map.bounds.init.southWest),A=L.latLng(n.map.bounds.init.northEast),B=L.latLngBounds(z,A)),_.has(n.map.bounds,"max")&&(C=L.latLng(n.map.bounds.max.southWest),D=L.latLng(n.map.bounds.max.northEast),E=L.latLngBounds(C,D))),y=L.map("map",{maxZoom:n.map.zoom.max||null,minZoom:n.map.zoom.min||null,zoom:("widget"!=w.md?n.map.zoom.init:n.map.zoom.init-1)||null,center:n.map.center||(B?B.getCenter():null),scrollWheelZoom:_.has(n.map.zoom,"scrollWheel")?n.map.zoom.scrollWheel:!0,attributionControl:!n.map.attribution.length,maxBounds:E||null}),!n.map.zoom.init&&B&&y.fitBounds(B),n.debug&&console.log("map",y);var F=n.geoLayers.filter(function(a){return"tile"===a.type});for(n.debug&&console.log("tileLayers",F),k=0;k<F.length;k++)L.tileLayer(F[k].url.call(F[k]),F[k].options).addTo(y);var G=L.control.attribution();for(k=0;k<n.map.attribution.length;k++)G.addAttribution(n.map.attribution[k]);n.debug&&console.log("attrib",G),G.addTo(y);var H;_.has(n,"infowindow")&&n.infowindow.active&&("widget"===w.md?H={_div:d3.select("body").append("div").attr("class","info bottom").node(),addTo:function(a){return this.onAdd(a),this}}:_.has(n.infowindow,"position")&&"inside"!=n.infowindow.position?(H={},d3.select("body").classed("summary "+n.infowindow.position,!0),"top"===n.infowindow.position||"left"===n.infowindow.position?H._div=d3.select("body").insert("div","#map").attr("class","info external "+n.infowindow.position).node():("right"===n.infowindow.position||"bottom"===n.infowindow.position)&&(H._div=d3.select("body").append("div").attr("class","info external "+n.infowindow.position).node()),H.addTo=function(a){return this.onAdd(a),this}):H=L.control({position:"bottomright"}),H.onAdd=function(a){return this._div=this._div||L.DomUtil.create("div","info "+w.md),d3.select(this._div).attr("id","infowindow").style("max-height","widget"!=w.md?head.screen.innerHeight-100+"px":null).classed("empty",function(){return"widget"===w.md?!(_.has(n.infowindow.content,"mobile")&&n.infowindow.content.mobile):!(_.has(n.infowindow.content,"default")&&n.infowindow.content.default)}).on("mouseenter",function(){a.scrollWheelZoom.disable(),a.doubleClickZoom.disable()}).on("mouseleave",function(){_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&a.scrollWheelZoom.enable(),a.doubleClickZoom.enable()}),this.update(),this._div},H.update=function(a){if(this._div.innerHTML="",a){d3.select(this._div).classed("closed",!1).classed("empty",!1),"widget"===w.md&&y.dragging.disable();var b,c,d,e=agnes.rowDelimiter(),f=new Date,g=d3.time.format("%Y%m%d")(f),h=a._layer,i=t[h].filter(function(a){return a.active})[0],j=i.id,l=a[r[h].id],o=[],q=[],s=_.isString(n.infowindow.path)?n.infowindow.path:"icons/";if(_.has(n.infowindow,"shareButtons")&&n.infowindow.shareButtons.active){var u=_.isString(n.infowindow.shareButtons.path)?n.infowindow.shareButtons.path:s;b=n.infowindow.shareButtons.title+("regioni"==h?" in ":" a ")+a[r[h].label],c="http://"+location.hostname+Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&"),btnEncUrl="http://"+location.hostname+encodeURIComponent(Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&")),d=a[r[h].label],n.infowindow.shareButtons.url&&(c=btnEncUrl=n.infowindow.shareButtons.url),_.has(n.infowindow.shareButtons,"twitter")&&n.infowindow.shareButtons.twitter.active&&o.push('<a class="ssb" href="http://twitter.com/share?url='+btnEncUrl+"&via="+n.infowindow.shareButtons.twitter.via+"&text="+encodeURIComponent(_.isFunction(n.infowindow.shareButtons.twitter.text)?n.infowindow.shareButtons.twitter.text(a._data[i.name]):d+" - "+n.infowindow.shareButtons.twitter.text)+'" target="_blank" title="'+b+' su Twitter"><img src="'+u+(n.infowindow.shareButtons.twitter.image||"twitter.png")+'" id="ssb-twitter"></a>'),_.has(n.infowindow.shareButtons,"facebook")&&n.infowindow.shareButtons.facebook.active&&o.push('<a class="ssb" href="http://www.facebook.com/sharer.php?u='+btnEncUrl+'" target="_blank" title="'+b+' su Facebook"><img src="'+u+(n.infowindow.shareButtons.facebook.image||"facebook.png")+'" id="ssb-facebook"></a>'),_.has(n.infowindow.shareButtons,"gplus")&&n.infowindow.shareButtons.gplus.active&&o.push('<a class="ssb" href="https://plus.google.com/share?url='+btnEncUrl+'" target="_blank" title="'+b+' su Google Plus"><img src="'+u+(n.infowindow.shareButtons.gplus.image||"gplus.png")+'" id="ssb-gplus"></a>'),_.has(n.infowindow.shareButtons,"linkedin")&&n.infowindow.shareButtons.linkedin.active&&o.push('<a class="ssb" href="http://www.linkedin.com/shareArticle?mini=true&url='+btnEncUrl+'" target="_blank" title="'+b+' su LinkedIn"><img src="'+u+(n.infowindow.shareButtons.linkedin.image||"linkedin.png")+'" id="ssb-linkedin"></a>'),_.has(n.infowindow.shareButtons,"email")&&n.infowindow.shareButtons.email.active&&o.push('<a class="ssb" href="mailto:?Subject='+encodeURIComponent(_.isFunction(n.infowindow.shareButtons.email.subject)?n.infowindow.shareButtons.email.subject(a._data[i.name]):n.infowindow.shareButtons.email.subject+" | "+d)+"&Body="+encodeURIComponent(_.isFunction(n.infowindow.shareButtons.email.body)?n.infowindow.shareButtons.email.body(a._data[i.name],btnEncUrl):d+" - "+n.infowindow.shareButtons.email.body+": "+c)+'" target="_blank" title="'+b+' per email"><img src="'+u+(n.infowindow.shareButtons.email.image||"email.png")+'" id="ssb-email"></a>'),_.has(n.infowindow.shareButtons,"permalink")&&n.infowindow.shareButtons.permalink.active&&o.push('<a class="ssb" href="'+c+'" target="_blank" title="Permalink"><img src="'+u+(n.infowindow.shareButtons.permalink.image||"link.png")+'" id="ssb-link"></a>')}if(n.debug&&console.log("shareButtons",o),_.has(n.infowindow,"downloads")&&n.infowindow.downloads.active){var v=_.isString(n.infowindow.downloads.path)?n.infowindow.downloads.path:s;for(k=0;k<n.infowindow.downloads.files.length;k++)n.infowindow.downloads.files[k].active&&(n.infowindow.downloads.files[k].datasets&&n.infowindow.downloads.files[k].datasets.length&&!_.contains(n.infowindow.downloads.files[k].datasets,i.name)||q.push('<a id="a-'+n.infowindow.downloads.files[k].name+'" class="dnl" href="'+(n.infowindow.downloads.files[k].filename?n.infowindow.downloads.files[k].url():"#")+'" title="'+n.infowindow.downloads.files[k].title+'"><img src="'+v+(n.infowindow.downloads.files[k].image||n.infowindow.downloads.image||"download.png")+'" /></a>'))}n.debug&&console.log("downloadButtons",q);var x,z='<thead><tr><th colspan="2">'+(q.length?'<span id="sdnlBtn">'+q.join(" ")+"</span> ":"")+(o.length?'<span id="sshrBtn">'+o.join(" ")+"</span>":"")+'<a id="close-cross" href="#" title="Chiudi"><img src="'+s+(n.infowindow.image||"close.png")+'" /></a></th></tr>'+(r[h].label?'<tr><th colspan="2" class="rossobc">'+a[r[h].label]+"</th></tr>":"")+"</thead>";x=_.has(n.infowindow,"downloads")&&n.infowindow.downloads.active?'<tfoot><tr><td colspan="2" style="text-align:right;font-size: smaller;">'+(n.infowindow.downloads.license||"")+"</td></tr></tfoot>":"<tfoot></tfoot>";var A;if(_.has(n.infowindow,"view")&&n.infowindow.view.active&&_.has(n.viewTypes,n.infowindow.view.type)?(A=n.viewTypes[n.infowindow.view.type](a._data[i.name],n.infowindow.view.options,i.formatter,i.groups),A.search("<tbody>")>-1||(A="<tbody>"+A+"</tbody>")):A="<tbody></tbody>",this._div.innerHTML+='<table class="zebra">'+z+A+x+"</table>",d3.selectAll("tr.first-level.group").on("click",function(a,b){d3.select(this).classed("open",!d3.select(this).classed("open")),d3.selectAll("tr.second-level.g"+(b+1)).classed("hidden",function(){return!d3.select(this).classed("hidden")})}),_.has(n.infowindow,"shareButtons")&&n.infowindow.shareButtons.active&&_.has(n,"urlShortener")&&n.urlShortener.active&&p.shorten(btnEncUrl,n.urlShortener.prefix+md5(c),function(a){var e=a.shorturl,f=[];_.has(n.infowindow.shareButtons,"twitter")&&n.infowindow.shareButtons.twitter.active&&f.push('<a class="ssb" href="http://twitter.com/share?url='+e+"&via="+n.infowindow.shareButtons.twitter.via+"&text="+encodeURIComponent(d+" - "+n.infowindow.shareButtons.twitter.text+" ")+'" target="_blank" title="'+b+' su Twitter"><img src="'+imagePath+(n.infowindow.shareButtons.twitter.image||"twitter.png")+'" id="ssb-twitter"></a>'),_.has(n.infowindow.shareButtons,"facebook")&&n.infowindow.shareButtons.facebook.active&&f.push('<a class="ssb" href="http://www.facebook.com/sharer.php?u='+e+'" target="_blank" title="'+b+' su Facebook"><img src="'+imagePath+(n.infowindow.shareButtons.facebook.image||"facebook.png")+'" id="ssb-facebook"></a>'),_.has(n.infowindow.shareButtons,"gplus")&&n.infowindow.shareButtons.gplus.active&&f.push('<a class="ssb" href="https://plus.google.com/share?url='+e+'" target="_blank" title="'+b+' su Google Plus"><img src="'+imagePath+(n.infowindow.shareButtons.gplus.image||"gplus.png")+'" id="ssb-gplus"></a>'),_.has(n.infowindow.shareButtons,"linkedin")&&n.infowindow.shareButtons.linkedin.active&&f.push('<a class="ssb" href="http://www.linkedin.com/shareArticle?mini=true&url='+e+'" target="_blank" title="'+b+' su LinkedIn"><img src="'+imagePath+(n.infowindow.shareButtons.linkedin.image||"linkedin.png")+'" id="ssb-linkedin"></a>'),_.has(n.infowindow.shareButtons,"email")&&n.infowindow.shareButtons.email.active&&f.push('<a class="ssb" href="mailto:?Subject='+encodeURIComponent(n.infowindow.shareButtons.email.subject+" | "+d)+"&Body="+encodeURIComponent(d+" - "+n.infowindow.shareButtons.email.body+": ")+e+'" target="_blank" title="'+b+' per email"><img src="'+imagePath+(n.infowindow.shareButtons.email.image||"email.png")+'" id="ssb-email"></a>'),_.has(n.infowindow.shareButtons,"permalink")&&n.infowindow.shareButtons.permalink.active&&f.push('<a class="ssb" href="'+c+'" target="_blank" title="Permalink"><img src="'+imagePath+(n.infowindow.shareButtons.permalink.image||"link.png")+'" id="ssb-link"></a>'),d3.select("#sshrBtn").node().innerHTML=f.join(" ")}),_.has(n.infowindow,"downloads")&&n.infowindow.downloads.active)for(k=0;k<n.infowindow.downloads.files.length;k++)n.infowindow.downloads.files[k].active&&!n.infowindow.downloads.files[k].filename&&!function(a){var b=n.infowindow.downloads.files[a].url.call(n.infowindow.downloads.files[a],h,j,l),c=g+"_"+n.infowindow.downloads.files[a].filebase+"-"+n.infowindow.downloads.files[a].name+(j&&l?"_"+j+"-"+l:"")+".csv";d3.select("a#a-"+n.infowindow.downloads.files[a].name).on("click",function(){n.debug&&console.log(this,a,n.infowindow.downloads.files[a].name,b,c),d3[n.infowindow.downloads.files[a].format](b,function(b,d){var f=n.infowindow.downloads.files[a].transform.call(n.infowindow.downloads.files[a],d);if(f.length>0){var g=agnes.jsonToCsv(f,e),h=new Blob([g],{type:"text/csv;charset=utf-8"});saveAs(h,c)}else alert("No data!")})})}(k);d3.select(this._div).select("a#close-cross").on("click",function(){return n.debug&&console.log("clickCloseCross",arguments),H.update(),!1})}else d3.select(this._div).classed("closed",!0).classed("empty",function(){return"widget"===w.md?!(_.has(n.infowindow.content,"mobile")&&n.infowindow.content.mobile):!(_.has(n.infowindow.content,"default")&&n.infowindow.content.default)}),m&&(m.feature._selected=!1,delete m.feature._position,cb.resetStyle(m),m=void 0),delete w.i,P&&P.isAdded&&P.removeFrom(y),_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&y.scrollWheelZoom.enable(),"widget"===w.md?(y.dragging.enable(),this._div.innerHTML+=n.infowindow.content.mobile):this._div.innerHTML+=n.infowindow.content.default},H.addTo(y)),n.debug&&console.log("info",H);var I;if(_.has(n.controls,"geocoder")&&n.controls.geocoder.active&&"widget"!=w.md&&(I=new L.Control.OSMGeocoder({collapsed:n.controls.geocoder.collapsed,position:"topright",text:n.controls.geocoder.title,bounds:B,email:n.controls.geocoder.email,type:"city",callback:function(a){if(n.debug&&console.log("osmGeocoderResults",a),a.length){var b=a[0].boundingbox,c=new L.LatLng(b[0],b[2]),d=new L.LatLng(b[1],b[3]),e=new L.LatLngBounds([c,d]);if(_.has(n.controls.geocoder,"layer")&&n.controls.geocoder.layer){H.update();var f=document.createEvent("UIEvents");f.initUIEvent("click",!0,!0,window,1),d3.select("#geomenu-ui #"+n.controls.geocoder.layer).node().dispatchEvent(f)}this._map.fitBounds(e,{maxZoom:n.controls.geocoder.zoom||null})}}}),y.addControl(I),_.has(n.controls.geocoder,"autocomplete")&&n.controls.geocoder.autocomplete.active)){I._completely=completely(I._input),I._completely.onChange=function(a){I._completely.startFrom=a.lastIndexOf(" ")+1,I._completely.repaint()},I._completely.input.maxLength=50;var J=n.controls.geocoder.autocomplete.url.call(n.controls.geocoder.autocomplete,w.t||void 0);d3[n.controls.geocoder.autocomplete.format](J,function(a,b){q[n.controls.geocoder.layer].list=n.controls.geocoder.autocomplete.transform.call(n.controls.geocoder.autocomplete,b),I._completely.options=q[n.controls.geocoder.layer].list.map(function(a){return a[r[n.controls.geocoder.layer].label]})})}n.debug&&console.log("osmGeocoder",I);var K;_.has(n.controls,"fullscreen")&&n.controls.fullscreen.active&&"widget"!=w.md&&"embed"!=w.md&&(K=L.control.fullscreen({title:n.controls.fullscreen.title}).addTo(y)),n.debug&&console.log("fullscreen",K);var M;_.has(n.controls,"logo")&&n.controls.logo.active&&("widget"===w.md?M=d3.select("body").insert("div","#map").attr("id","logo-widget").append("a").classed("logo "+w.md,!0).attr("href",n.controls.logo.link||"#").attr("target","_blank").append("img").attr("id","logo").attr("src",n.controls.logo.image):(M=L.control({position:"topleft"}),M.onAdd=function(){var a=L.DomUtil.create("a","logo "+w.md),b=L.DomUtil.create("img","logo"+(n.controls.logo.border?" border":""),a);return a.setAttribute("href",n.controls.logo.link||"#"),a.setAttribute("target","_blank"),b.setAttribute("id","logo"),b.setAttribute("src",n.controls.logo.image),a},M.addTo(y))),n.debug&&console.log("logo",M);var N;_.has(n.controls,"reset")&&n.controls.reset.active&&(N=L.control({position:"widget"===w.md?"bottomleft":"topright"}),N.onAdd=function(a){var b=L.DomUtil.create("img","reset "+w.md);return b.setAttribute("src",n.controls.reset.image),b.setAttribute("title",n.controls.reset.title),d3.select(b).on("click",function(){if(H.update(),!n.map.zoom.init&&B?a.fitBounds(B):a.setView(n.map.center||(B?B.getCenter():null),"widget"!=w.md?n.map.zoom.init:n.map.zoom.init-1),d3.select("#geomenu-ui #"+w.ml).classed("active"))W.onChange(w.ml);else{var b=document.createEvent("UIEvents");b.initUIEvent("click",!0,!0,window,1),d3.select("#geomenu-ui #"+w.ml).node().dispatchEvent(b)}_.has(n.controls,"geocoder")&&n.controls.geocoder.active&&(d3.select(".leaflet-control-geocoder input").node().value="")}),b},N.addTo(y)),n.debug&&console.log("reset",N);var O,P;_.has(n.controls,"embed")&&n.controls.embed.active&&(P=L.control({position:"widget"===w.md?"bottomleft":"topright"}),P.isAdded=!1,P.onRemove=function(){this.isAdded=!1},P.onAdd=function(){this.isAdded=!0;var a={},b=L.DomUtil.create("div","info embed-inputarea"),c="http://"+location.hostname+Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&"),d="http://"+location.hostname+encodeURIComponent(Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&"));n.controls.embed.permalink&&(a.permalink=L.DomUtil.create("p","permalink",b),a.permalink.innerHTML='<label for="embed-permalink" title="Clicca per selezionare">Permalink:</label> <input type="text" id="embed-permalink" value="'+c+'" readonly></input>'),_.has(n,"urlShortener")&&n.urlShortener.active&&n.controls.embed.shorturl&&(a.shorturl=L.DomUtil.create("p","shorturl",b),a.shorturl.innerHTML='<label for="embed-shorturl" title="Clicca per selezionare">Short URL:</label> <input type="text" id="embed-shorturl" value="Not available..." disabled readonly></input>',p.shorten(d,n.urlShortener.prefix+md5(c),function(a){d3.select("input#embed-shorturl").attr("value",a.shorturl).attr("disabled",null)})),n.controls.embed.iframe&&(a.iframe=L.DomUtil.create("p","iframe",b),a.iframe.innerHTML='<label for="embed-iframe" title="Clicca per selezionare">Embed in post/page:</label> <input type="text" id="embed-iframe" value="<iframe src="'+c+'&md=embed" frameborder="0" allowtransparency="true" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen width="100%" height="700"></iframe>" readonly></input>'),n.controls.embed.widget&&(a.widget=L.DomUtil.create("p","widget",b),a.widget.innerHTML='<label for="embed-widget" title="Clicca per selezionare">Embed in sidebar:</label> <input type="text" id="embed-widget" value="<iframe src="'+c+'&md=widget" frameborder="0" allowtransparency="true" allowfullscreen webkitallowfullscreen mozallowfullscreen oallowfullscreen msallowfullscreen width="100%" height="755"></iframe>" readonly></input>'),n.controls.embed.shortcode&&(a.shortcode=L.DomUtil.create("p","shortcode",b),a.shortcode.innerHTML='<label for="embed-shortcode" title="Clicca per selezionare">WP Shortcode (<a href="https://github.com/Dataninja/wp-cbmap-shortcode" target="_blank">?</a>):</label> <input type="text" id="embed-shortcode" value="[cbmap '+decodeURIComponent(c).replace(/^[^?]+\?/,"").replace(/&/g," ")+' md=embed]" readonly></input>'),_.has(n.controls.embed,"svg")&&n.controls.embed.svg.active&&(a.svg=L.DomUtil.create("p","svg",b),a.svg.innerHTML='<label for="embed-svg" title="Copia/incolla il codice o scaricalo cliccando sull\'immagine">Scalable Vector Graphics:</label> <textarea id="embed-svg" readonly>'+d3.select(".leaflet-overlay-pane")[0][0].innerHTML.replace(/\>/g,">\n")+'</textarea> <img src="'+n.controls.embed.svg.image+'" title="Scarica l\'immagine in SVG">',d3.select(a.svg).select("img").on("click",function(){var a=new Blob([d3.select(".leaflet-overlay-pane")[0][0].innerHTML.replace(/\>/g,">\n")],{type:"image/svg+xml;charset=utf-8"});
saveAs(a,n.controls.embed.svg.filename)}));for(var e in a)_.has(a,e)&&d3.select(a[e]).select("input").on("focus",function(){this.select()});return b},O=L.control({position:"widget"===w.md?"bottomleft":"topright"}),O.onAdd=function(a){var b=L.DomUtil.create("img","embed "+w.md);return b.setAttribute("src",n.controls.embed.image),b.setAttribute("title",n.controls.embed.title),d3.select(b).on("click",function(){P.isAdded?P&&P.isAdded&&P.removeFrom(a):P.addTo(a)}),b},O.addTo(y)),n.debug&&console.log("embed",O);var Q;_.has(n.controls,"screenshot")&&n.controls.screenshot.active&&"widget"!=w.md&&(Q=L.control({position:"widget"===w.md?"bottomleft":"topright"}),Q.onAdd=function(){var a=L.DomUtil.create("img","screenshot "+w.md);return a.setAttribute("id","screenshot"),a.setAttribute("src",n.controls.screenshot.image),a.setAttribute("title",n.controls.screenshot.title),d3.select(a).on("click",function(){html2canvas(document.body,{onrendered:function(a){var b=d3.select(".leaflet-overlay-pane svg"),c=n.controls.screenshot.offsetX||"auto",d=n.controls.screenshot.offsetY||"auto";canvg(a,b.node().outerHTML,{ignoreMouse:n.controls.screenshot.ignoreMouse||!0,ignoreAnimation:n.controls.screenshot.ignoreAnimation||!0,ignoreDimensions:n.controls.screenshot.ignoreDimensions||!0,ignoreClear:n.controls.screenshot.ignoreClear||!0,offsetX:_.isNumber(c)?c:j[0],offsetY:_.isNumber(d)?d:j[1]}),a.toBlob(function(a){saveAs(a,n.controls.screenshot.filename)})}})}),a},Q.addTo(y)),n.debug&&console.log("screenshot",Q);var R;_.has(n.controls,"detach")&&n.controls.detach.active&&("embed"===w.md||"widget"===w.md)&&(R=L.control({position:"topright"}),R.onAdd=function(){var a=L.DomUtil.create("a","detach "+w.md),b=L.DomUtil.create("img","detach",a);return a.setAttribute("href",n.controls.detach.url||Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&")),a.setAttribute("target","_blank"),a.setAttribute("title",n.controls.detach.title),b.setAttribute("id","detach"),b.setAttribute("src",n.controls.detach.image),d3.select(a).on("click",function(){this.setAttribute("href",Arg.url(w).replace(/&*md=[^&]*/,"").replace(/&{2,}/g,"&"))}),a},R.addTo(y)),n.debug&&console.log("detach",R);var S,T;_.has(n,"summary")&&n.summary.active&&"widget"!=w.md&&(n.summary.position=n.summary.position||"right",d3.select("body").classed("summary "+n.summary.position,!0),S="top"===n.summary.position||"left"===n.summary.position?d3.select("body").insert("div","#map"):d3.select("body").append("div"),S.attr("id","map-summary").attr("class","summary "+n.summary.position).append("div").html(n.summary.content||""),T=L.control({position:"topright"}),_.has(n.summary,"closed")&&n.summary.closed?(T.isAdded=!1,S.style("display","none"),d3.select("body").classed("summary",!1)):(T.isAdded=!0,S.style("display",null),d3.select("body").classed("summary",!0)),T.onAdd=function(){var a=L.DomUtil.create("img","summary "+w.md),b=this;return a.setAttribute("src",n.summary.image),a.setAttribute("title",n.summary.title),d3.select(a).on("click",function(){d3.select("#map-summary").style("display",b.isAdded?"none":null),d3.select("body").classed("summary",!b.isAdded),b.isAdded=!b.isAdded}),a},T.addTo(y)),n.debug&&console.log("summaryControl",T);var U;_.has(n.controls,"socialButtons")&&n.controls.socialButtons.active&&(w.md||(U=L.control({position:"bottomleft"}),U.onAdd=function(){var a=L.DomUtil.create("div","share "+w.md),b="",c="",d="";return a.setAttribute("id","buttons"),a.innerHTML="",_.has(n.controls.socialButtons,"twitter")&&n.controls.socialButtons.twitter.active&&(b='<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://'+location.hostname+location.pathname+'" data-via="'+n.controls.socialButtons.twitter.via+'" data-lang="'+n.controls.socialButtons.twitter.lang+'" data-related="'+n.controls.socialButtons.twitter.related+'" data-hashtags="'+n.controls.socialButtons.twitter.hashtags+'" data-count="'+n.controls.socialButtons.twitter.count+'">'+n.controls.socialButtons.twitter.text+"</a>",a.innerHTML+=b,head.load("https://platform.twitter.com/widgets.js")),_.has(n.controls.socialButtons,"facebook")&&n.controls.socialButtons.facebook.active&&(c='<div class="fb-like" style="overflow:hidden;" data-href="http://'+location.hostname+location.pathname+'" data-layout="'+n.controls.socialButtons.facebook.layout+'" data-action="'+n.controls.socialButtons.facebook.action+'" data-show-faces="'+n.controls.socialButtons.facebook["show-faces"].toString()+'" data-share="'+n.controls.socialButtons.facebook.share.toString()+'"></div>',a.innerHTML+=c,head.load("http://connect.facebook.net/it_IT/sdk.js#xfbml=1&appId="+n.controls.socialButtons.facebook.appId+"&version=v2.0")),_.has(n.controls.socialButtons,"gplus")&&n.controls.socialButtons.gplus.active&&(d='<div class="g-plusone" data-size="'+n.controls.socialButtons.gplus.size+'" data-href="http://'+location.hostname+location.pathname+'" data-annotation="'+n.controls.socialButtons.gplus.annotation+'"></div>',a.innerHTML+=d,head.load("https://apis.google.com/js/plusone.js")),a},U.addTo(y))),n.debug&&console.log("share",U);var V;_.has(n,"legend")&&n.legend.active&&(V=L.control({position:"bottomleft"}),V.onAdd=function(){return this._div=L.DomUtil.create("div","info legend "+w.md),this._div},V.update=function(a){if(a){var b=t[a].filter(function(a){return a.active})[0],c=n.legend.delimiter||"-",d=b.ranges.map(function(a){return a.split(" - ").map(function(a){var c=parseFloat(a);return b.formatter(b.column,c)}).join(" "+c+" ")}),e=b.description||n.legend.description||"",f=b.palette.replace("~",""),g=colorbrewer[f][d.length]?d.length:3,h="~"===b.palette[0]?_.clone(colorbrewer[f][g]).reverse():colorbrewer[f][g];this._div.innerHTML="widget"!=w.md?'<h3 title="'+e+'">'+n.legend.title+"</h3>":"";for(var i=0;i<d.length;i++)this._div.innerHTML+='<i title="'+(_.has(n.legend,"label")?n.legend.label.call(n.legend,d[i].split(" "+c+" ")[0],d[i].split(" "+c+" ")[1],b.label):d[i])+'" style="background:'+h[i]+'"></i> '+("widget"!=w.md?n.legend.label.call(n.legend,d[i].split(" "+c+" ")[0],d[i].split(" "+c+" ")[1]):"")+"<br>";"widget"!=w.md&&(this._div.innerHTML+="<p>"+e+"</p>")}else this._div.innerHTML="widget"!=w.md?"<h3>"+n.legend.title+"</h3>":""},V.addTo(y),V.update()),n.debug&&console.log("legend",V);var W,X=_.has(n,"menu")?n.menu.maxItems||3:3,Y=n.geoLayers.filter(function(a){return"tile"!=a.type});W="widget"===w.md?{_nav:d3.select("body").insert("nav","#map").node(),addTo:function(a){return this.onAdd(a),this}}:L.control({position:"topleft"}),W.onAdd=function(a){return this._nav=this._nav||L.DomUtil.create("nav"),d3.select(this._nav).attr("id","geomenu-ui").attr("class","menu-ui "+w.md).style("display","none").on("mouseenter",function(){a.scrollWheelZoom.disable(),a.doubleClickZoom.disable(),a.dragging.disable()}).on("mouseleave",function(){_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&a.scrollWheelZoom.enable(),a.doubleClickZoom.enable(),a.dragging.enable()}),this.update(),this._nav},W.onChange=function(a){n.debug&&console.log("geoMenuOnChange",arguments,a);var b=n.geoLayers.filter(function(b){return"thematic"===b.type&&b.schema.name===a})[0];b.zoom?(y.setZoom(b.zoom),y.options.maxZoom=b.zoom,y.options.minZoom=b.zoom):(y.options.maxZoom=n.map.zoom.max||null,y.options.minZoom=n.map.zoom.min||null),t[a][0].active=!0;for(var c=0;c<t[a].length;c++)0!=c&&(t[a][c].active=!1);H.update(),Z.update(a),Z.onChange(a)},W.update=function(){d3.select(this._nav).style("width",null).selectAll("a").remove();var a=this;if(d3.select(this._nav).selectAll("a").data(Y.map(function(a){return a.schema})).enter().append("a").attr("href","#").attr("id",function(a){return a.name}).attr("class",function(a,b){return 0===b?"first-item active":b===Y.length-1?"last-item":""}).classed("disabled",function(a){return!_.has(r,a.name)}).on("click",function(b){var c=d3.select(this).on("click");_.has(r,b.name)&&(d3.select(a._nav).select("a.active").classed("active",!1).on("click",c).on("mouseout",null),d3.select(a._nav).selectAll("a").style("display",null),d3.select(this).classed("active",!0).style("display","block").on("click",function(){d3.select(a._nav).classed("open")?d3.select(a._nav).classed("open",!1).selectAll("a").style("display",null):d3.select(a._nav).classed("open",!0).selectAll("a").style("display","block")}).on("mouseout",function(){d3.select(a._nav).classed("open",!1).selectAll("a").style("display",null)}),console.log(b.name),a.onChange(b.name))}).text(function(a){return a.menu}),Y.length>1){var b=d3.max(Y.map(function(a){return a.schema.menu.length}));d3.select(this._nav).style("display",null).classed("collapsable",!1).style("width",function(){return"widget"!=w.md&&Y.length>X?d3.select(this).selectAll("a").filter(function(a){return a.menu.length===b})[0][0].offsetWidth+15+"px":null}).classed("collapsable",Y.length>X)}else d3.select(this._nav).style("display","none")},n.debug&&console.log("menuGeoLayers",Y),n.debug&&console.log("geoMenu",W);var Z;Z="widget"===w.md?{_nav:d3.select("body").insert("nav","#map").node(),addTo:function(a){return this.onAdd(a),this}}:L.control({position:"topleft"}),Z.onAdd=function(a){return this._nav=this._nav||L.DomUtil.create("nav"),d3.select(this._nav).attr("id","datamenu-ui").attr("class","menu-ui "+w.md).style("display","none").on("mouseenter",function(){a.scrollWheelZoom.disable(),a.doubleClickZoom.disable(),a.dragging.disable()}).on("mouseleave",function(){_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&a.scrollWheelZoom.enable(),a.doubleClickZoom.enable(),a.dragging.enable()}),this._nav},Z.onChange=function(a,b){var b=b||0,c=t[a][b];n.debug&&console.log("dataMenuOnChange",arguments,a,b,c),c.active=!0;for(var d=0;d<t[a].length;d++)d!=b&&(t[a][d].active=!1);m?H.update(m.feature.properties):H.update(),$.update(a,b),$.onChange(a,b)},Z.update=function(a){d3.select(this._nav).style("width",null).selectAll("a").remove();var b=this,c=t[a];if(d3.select(this._nav).selectAll("a").data(c).enter().append("a").attr("href","#").attr("id",function(a){return a.name}).attr("title",function(a){return a.description}).attr("class",function(a,b){return 0===b?"first-item active":b===c.length-1?"last-item":""}).on("click",function(a){var c=d3.select(this).on("click");d3.select(b._nav).select("a.active").classed("active",!1).on("click",c).on("mouseout",null),d3.select(b._nav).selectAll("a").style("display",null),d3.select(this).classed("active",!0).style("display","block").on("click",function(){d3.select(b._nav).classed("open")?d3.select(b._nav).classed("open",!1).selectAll("a").style("display",null):d3.select(b._nav).classed("open",!0).selectAll("a").style("display","block")}).on("mouseout",function(){d3.select(b._nav).classed("open",!1).selectAll("a").style("display",null)}),b.onChange(a.layer,a.index)}).text(function(a){return a.menuLabel}),c.length>1){var d=d3.max(c.map(function(a){return a.menuLabel.length}));d3.select(this._nav).style("display",null).classed("collapsable",!1).style("width",function(){return"widget"!=w.md&&c.length>X?d3.select(this).selectAll("a").filter(function(a){return a.menuLabel.length===d})[0][0].offsetWidth+15+"px":null}).classed("collapsable",c.length>X)}else d3.select(this._nav).style("display","none")},n.debug&&console.log("dataMenu",Z);var $;$="widget"===w.md?{_nav:d3.select("body").insert("nav","#map").node(),addTo:function(a){return this.onAdd(a),this}}:L.control({position:"topleft"}),$.onAdd=function(a){return this._nav=this._nav||L.DomUtil.create("nav"),d3.select(this._nav).attr("id","varmenu-ui").attr("class","menu-ui "+w.md).style("display","none").on("mouseenter",function(){a.scrollWheelZoom.disable(),a.doubleClickZoom.disable(),a.dragging.disable()}).on("mouseleave",function(){_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&a.scrollWheelZoom.enable(),a.doubleClickZoom.enable(),a.dragging.enable()}),this._nav},$.onChange=function(a,b,c){var b=b||0,c=c||0,d=t[a][b];n.debug&&console.log("varMenuOnChange",arguments,a,b,c,d),V.update(),d.column=d.columns[c],d.label=d.labels[c],d.description=d.descriptions[c],d.precision=d.precisions[c],d.binsNum=d.binsNums[c],i(a,d.name)},$.update=function(a,b){d3.select(this._nav).style("width",null).selectAll("a").remove();for(var c=this,b=b||0,d=t[a][b],e=[],f=!0,g="",h=0;h<d.columns.length;h++)_.has(d.groups,d.columns[h])?(d.groups[d.columns[h]]!=g&&(g=d.groups[d.columns[h]],e.push({label:g,enabled:!1,level:"first-level"})),e.push({label:d.labels[h],descr:d.descriptions[h],enabled:!0,level:"second-level"})):e.push({label:d.labels[h],descr:d.descriptions[h],enabled:!0,level:"first-level"});if(d.columns)if(d3.select(this._nav).selectAll("a").data(e).enter().append("a").attr("href","#").attr("title",function(a){return a.descr}).attr("class",function(a,b){var c="";return 0===b?c="first-item":b===e.length-1&&(c="last-item"),f&&a.enabled&&(f=!1,c+=" active"),c+" "+a.level+" "+(a.enabled?"enabled":"disabled")}).on("click",function(e){var f=d3.select(this).on("click");if(e.enabled){var g=_.indexOf(d.labels,e.label);d3.select(c._nav).select("a.active").classed("active",!1).on("click",f).on("mouseout",null),d3.select(c._nav).selectAll("a").style("display",null),d3.select(this).classed("active",!0).style("display","block").on("click",function(){d3.select(c._nav).classed("open")?d3.select(c._nav).classed("open",!1).selectAll("a").style("display",null):d3.select(c._nav).classed("open",!0).selectAll("a").style("display","block")}).on("mouseout",function(){d3.select(c._nav).classed("open",!1).selectAll("a").style("display",null)}),c.onChange(a,b,g)}}).text(function(a){return a.label}),d.columns.length>1){var i=d3.max(e.map(function(a){return a.label.length}));d3.select(this._nav).style("display",null).classed("collapsable",!1).style("width",function(){return"widget"!=w.md&&d.columns.length>X?d3.select(this).selectAll("a").filter(function(a){return a.label.length===i})[0][0].offsetWidth+15+"px":null}).classed("collapsable",d.columns.length>X)}else d3.select(this._nav).style("display","none");else d3.select(this._nav).style("display","none")},n.debug&&console.log("varMenu",$),W.addTo(y),Z.addTo(y),$.addTo(y),W.onChange(Y[0].schema.name);var ab;if(n.debug&&(ab=L.control({position:"bottomright"}),ab.onAdd=function(a){var b=L.DomUtil.create("div","devutil");return d3.select(b).append("p").attr("id","devutil-coord").text("Mouse position: ..."),d3.select(b).append("p").attr("id","devutil-sw").text("SouthWest bound: "+a.getBounds().getSouthWest().toString()),d3.select(b).append("p").attr("id","devutil-ne").text("NorthEast bound: "+a.getBounds().getNorthEast().toString()),d3.select(b).append("p").attr("id","devutil-center").text("Map center: "+a.getCenter().toString()),d3.select(b).append("p").attr("id","devutil-zoom").text("Zoom level: "+a.getZoom()),d3.select(b).append("p").attr("id","devutil-screen").text("Screen size: "+head.screen.innerWidth+" x "+head.screen.innerHeight),d3.select(b).on("mouseenter",function(){a.scrollWheelZoom.disable(),a.doubleClickZoom.disable(),a.dragging.disable()}).on("mouseleave",function(){_.has(n.map.zoom,"scrollWheel")&&n.map.zoom.scrollWheel&&a.scrollWheelZoom.enable(),a.doubleClickZoom.enable(),a.dragging.enable()}),b},ab.addTo(y),y.on("mousemove",function(a){d3.select("#devutil-coord").text("Mouse position: "+a.latlng.toString())}).on("move",function(){d3.select("#devutil-sw").text("SouthWest bound: "+y.getBounds().getSouthWest().toString()),d3.select("#devutil-ne").text("NorthEast bound: "+y.getBounds().getNorthEast().toString()),d3.select("#devutil-center").text("Map center: "+y.getCenter().toString())}).on("zoomend",function(){d3.select("#devutil-zoom").text("Zoom level: "+y.getZoom())})),n.pointsSet&&n.pointsSet.active&&n.pointsSet.resourceId){var bb=n.pointsSet.url.call(n.pointsSet);n.debug&&console.log("markersPath",bb),d3[n.pointsSet.format](bb,function(a,b){n.debug&&console.log("markers",arguments);var c=b?n.pointsSet.transform.call(n.pointsSet,b):null;if(c){for(var d=new L.MarkerClusterGroup({showCoverageOnHover:!1}),e=[],f=0;f<c.length;f++){var g=L.marker();g.setIcon(L.icon({iconUrl:n.pointsSet.icon,shadowUrl:n.pointsSet.shadow})),g.setLatLng(L.latLng(c[f][w.mr.lat],c[f][w.mr.lng])),_.has(w.mr,"iw")&&g.bindPopup(c[f][w.mr.iw]),e.push(g),d.addLayer(g)}y.addLayer(n.pointsSet.clusters?d:L.layerGroup(e))}})}var cb,db=new L.Label;cb=L.geoJson("",{style:b,onEachFeature:f}).addTo(y),n.debug&&console.log("geojson",cb)})}(mapConfig);