From b5cc75dc138bb60c19b57370e7f71bf1b1d09a1a Mon Sep 17 00:00:00 2001 From: kaveh Date: Tue, 29 May 2018 11:02:43 -0700 Subject: [PATCH] Add `updateOpacity` to `options` --- CHANGELOG.md | 7 +- README.md | 29 +++--- dist/L.Control.HtmlLegend.js | 2 +- dist/L.Control.HtmlLegend.js.map | 2 +- index.html | 146 ++++++++++++++++++++++++++----- package.json | 20 ++--- src/L.Control.HtmlLegend.js | 8 +- 7 files changed, 159 insertions(+), 55 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0655cba..b930d35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -0.2.3 (2017-11-13) +0.3.1 (2018-05-29) + * Add `updateOpacity` to `options` + - A new method that allows to use a custom function for adjusting layers opacity + * Fix version + +0.3.0 (2017-11-13) * Add `addLegend` - A new method to add legends to existing instances of HtmlLegend diff --git a/README.md b/README.md index a994d1c..340cb9f 100644 --- a/README.md +++ b/README.md @@ -29,22 +29,19 @@ Include the JavaScript: ``` -Options: -``` -{ - position: 'topright', - legends: [], // array of legend entries. see below for the structure - collapseSimple: false, // if true, legend entries that are from a simple renderer will use compact presentation - detectStretched: false, // if true, will test to see if legend entries look stretched. These are usually in sets of 3 with the middle element having no label. - collapsedOnInit: false, // if true, legends will be collapsed when a new instance is initialized. - defaultOpacity: 1, // default opacity for layers in specified in legends. - visibleIcon: 'leaflet-html-legend-icon-eye', // css class for the visible icon on opacity slider - hiddenIcon: 'leaflet-html-legend-icon-eye-slash', // css class for the hidden icon on opacity slider - toggleIcon: 'leaflet-html-legend-icon-eye-slash' // css class for the icon on visibility toggle button -} -``` - - +#### Options: +| Option | Type | Default | Description | +| :--- | :--- | :--- | :--- | +| position | String | 'topright' | Map position of element | +| legend | Array | - | Array of legend entries (see below for the structure) | +| collapseSimple | bool | false | Whether to use compact presentation for legend entries that are from a simple renderer | +| detectStreched | bool | false | Test to see if legend entries look stretched (these are usually in sets of 3 with the middle element having no label) | +| collapsedOnInit | bool | false | Whether to initialize instance in collapsed mode | +| updateOpacity | function | null | If set, this function is used to update opacity of the attached layer (it receives the layer and opacity as arguments) | +| defaultOpacity | number | 1 | Default opacity for layers in specified in legends | +| visibleIcon | String | 'leaflet-html-legend-icon-eye' | css class for the visible icon on opacity slider | +| hiddenIcon | String | 'leaflet-html-legend-icon-eye-slash' | css class for the hidden icon on opacity slider | +| toggleIcon | String | 'leaflet-html-legend-icon-eye-slash' | css class for the icon on visibility toggle button | Each entry in `legends` array can have the following keys: * name diff --git a/dist/L.Control.HtmlLegend.js b/dist/L.Control.HtmlLegend.js index e0a5a16..e3cee21 100644 --- a/dist/L.Control.HtmlLegend.js +++ b/dist/L.Control.HtmlLegend.js @@ -1,2 +1,2 @@ -!function(e){function t(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var i={};t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,i){"use strict";var n=function(){function e(e,t){var i=[],n=!0,a=!1,l=void 0;try{for(var o,r=e[Symbol.iterator]();!(n=(o=r.next()).done)&&(i.push(o.value),!t||i.length!==t);n=!0);}catch(e){a=!0,l=e}finally{try{!n&&r.return&&r.return()}finally{if(a)throw l}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();L.Control.HtmlLegend=L.Control.extend({_map:null,_activeLayers:0,_alwaysShow:!1,options:{position:"topright",legends:[],collapseSimple:!1,detectStretched:!1,collapsedOnInit:!1,defaultOpacity:1,visibleIcon:"leaflet-html-legend-icon-eye",hiddenIcon:"leaflet-html-legend-icon-eye-slash",toggleIcon:"leaflet-html-legend-icon-eye"},onAdd:function(e){return this._map=e,this._container=L.DomUtil.create("div","leaflet-control leaflet-bar leaflet-html-legend"),L.DomEvent.disableClickPropagation(this._container),L.DomEvent.disableScrollPropagation(this._container),this.render(),this._container},render:function(){L.DomUtil.empty(this._container),this.options.legends.forEach(this._renderLegend,this),this._checkVisibility()},addLegend:function(e){this.options.legends.push(e),this._map&&this._renderLegend(e)},_renderLegend:function(e){var t=this;if(e.elements){var i=e.elements,n="legend-block";this.options.detectStretched&&3===i.length&&""!==i[0].label&&""===i[1].label&&""!==i[2].label&&(n+=" legend-stretched");var a=L.DomUtil.create("div",n,this._container);if(this.options.collapseSimple&&1===i.length&&!i[0].label)return this._addElement(i[0].html,e.name,i[0].style,a),void this._connectLayer(a,e);if(e.name){var l=L.DomUtil.create("h4",null,a);L.DomUtil.create("div","legend-caret",l),L.DomUtil.create("span",null,l).innerHTML=e.name,this.options.collapsedOnInit&&L.DomUtil.addClass(l,"closed"),L.DomEvent.on(l,"click",function(){L.DomUtil.hasClass(l,"closed")?L.DomUtil.removeClass(l,"closed"):L.DomUtil.addClass(l,"closed")},this)}var o=L.DomUtil.create("div","legend-elements",a);i.forEach(function(e){t._addElement(e.html,e.label,e.style,o)},this),this._connectLayer(a,e)}},_addElement:function(e,t,i,a){var l=L.DomUtil.create("div","legend-row",a),o=L.DomUtil.create("span","symbol",l);i&&Object.entries(i).forEach(function(e){var t=n(e,2),i=t[0],a=t[1];o.style[i]=a}),o.innerHTML=e,t&&(L.DomUtil.create("label",null,l).innerHTML=t)},_updateOpacity:function(e,t){"function"==typeof e.setOpacity?e.setOpacity(t):"function"==typeof e.setStyle&&e.setStyle({opacity:t})},_connectLayer:function(e,t){var i=this,n=t.layer;if(!n)return void(this._alwaysShow=!0);var a=n.opacity||this.options.defaultOpacity||1;this._updateOpacity(n,a),this._map.hasLayer(n)?this._activeLayers+=1:e.style.display="none",e.classList.add("layer-control");var l=L.DomUtil.create("i","visibility-toggle "+this.options.toggleIcon,e);l.dataset.visibileOpacity=a,L.DomEvent.on(l,"click",function(e){var t=e.target;L.DomUtil.hasClass(t,"disabled")?(L.DomUtil.removeClass(t,"disabled"),i._updateOpacity(n,t.dataset.visibileOpacity)):(L.DomUtil.addClass(t,"disabled"),i._updateOpacity(n,0))});var o=L.DomUtil.create("span","opacity-slider",e);L.DomUtil.create("span","slider-label",o).innerHTML="Transparency:",L.DomUtil.create("i",this.options.visibleIcon,o);var r=L.DomUtil.create("input",null,o);r.type="range",r.min=0,r.max=1,r.step=.1,r.onchange=function(e){var t=1-e.target.value||0;i._updateOpacity(n,t),l.dataset.visibileOpacity=t,L.DomUtil.removeClass(l,"disabled")},r.value=1-a,L.DomUtil.create("i",this.options.hiddenIcon,o),this._map.on("layeradd",function(t){t.layer===n&&(i._activeLayers+=1,e.style.display="",i._checkVisibility())}).on("layerremove",function(t){t.layer===n&&(i._activeLayers-=1,e.style.display="none",i._checkVisibility())})},_checkVisibility:function(){this._alwaysShow||this._activeLayers?this._container.style.display="":this._container.style.display="none"}}),L.control.htmllegend=function(e){return new L.Control.HtmlLegend(e)}}]); +!function(e){function t(n){if(i[n])return i[n].exports;var a=i[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var i={};t.m=e,t.c=i,t.d=function(e,i,n){t.o(e,i)||Object.defineProperty(e,i,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var i=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(i,"a",i),i},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,i){"use strict";var n=function(){function e(e,t){var i=[],n=!0,a=!1,l=void 0;try{for(var o,r=e[Symbol.iterator]();!(n=(o=r.next()).done)&&(i.push(o.value),!t||i.length!==t);n=!0);}catch(e){a=!0,l=e}finally{try{!n&&r.return&&r.return()}finally{if(a)throw l}}return i}return function(t,i){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,i);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();L.Control.HtmlLegend=L.Control.extend({_map:null,_activeLayers:0,_alwaysShow:!1,options:{position:"topright",legends:[],collapseSimple:!1,detectStretched:!1,collapsedOnInit:!1,updateOpacity:null,defaultOpacity:1,visibleIcon:"leaflet-html-legend-icon-eye",hiddenIcon:"leaflet-html-legend-icon-eye-slash",toggleIcon:"leaflet-html-legend-icon-eye"},onAdd:function(e){return this._map=e,this._container=L.DomUtil.create("div","leaflet-control leaflet-bar leaflet-html-legend"),L.DomEvent.disableClickPropagation(this._container),L.DomEvent.disableScrollPropagation(this._container),this.render(),this._container},render:function(){L.DomUtil.empty(this._container),this.options.legends.forEach(this._renderLegend,this),this._checkVisibility()},addLegend:function(e){this.options.legends.push(e),this._map&&this._renderLegend(e)},_renderLegend:function(e){var t=this;if(e.elements){var i=e.elements,n="legend-block";this.options.detectStretched&&3===i.length&&""!==i[0].label&&""===i[1].label&&""!==i[2].label&&(n+=" legend-stretched");var a=L.DomUtil.create("div",n,this._container);if(this.options.collapseSimple&&1===i.length&&!i[0].label)return this._addElement(i[0].html,e.name,i[0].style,a),void this._connectLayer(a,e);if(e.name){var l=L.DomUtil.create("h4",null,a);L.DomUtil.create("div","legend-caret",l),L.DomUtil.create("span",null,l).innerHTML=e.name,this.options.collapsedOnInit&&L.DomUtil.addClass(l,"closed"),L.DomEvent.on(l,"click",function(){L.DomUtil.hasClass(l,"closed")?L.DomUtil.removeClass(l,"closed"):L.DomUtil.addClass(l,"closed")},this)}var o=L.DomUtil.create("div","legend-elements",a);i.forEach(function(e){t._addElement(e.html,e.label,e.style,o)},this),this._connectLayer(a,e)}},_addElement:function(e,t,i,a){var l=L.DomUtil.create("div","legend-row",a),o=L.DomUtil.create("span","symbol",l);i&&Object.entries(i).forEach(function(e){var t=n(e,2),i=t[0],a=t[1];o.style[i]=a}),o.innerHTML=e,t&&(L.DomUtil.create("label",null,l).innerHTML=t)},_updateOpacity:function(e,t){"function"==typeof this.options.updateOpacity?this.options.updateOpacity(e,t):"function"==typeof e.setOpacity?e.setOpacity(t):"function"==typeof e.setStyle&&e.setStyle({opacity:t})},_connectLayer:function(e,t){var i=this,n=t.layer;if(!n)return void(this._alwaysShow=!0);var a=n.opacity||this.options.defaultOpacity||1;this._updateOpacity(n,a),this._map.hasLayer(n)?this._activeLayers+=1:e.style.display="none",e.classList.add("layer-control");var l=L.DomUtil.create("i","visibility-toggle "+this.options.toggleIcon,e);l.dataset.visibileOpacity=a,L.DomEvent.on(l,"click",function(e){var t=e.target;L.DomUtil.hasClass(t,"disabled")?(L.DomUtil.removeClass(t,"disabled"),i._updateOpacity(n,t.dataset.visibileOpacity)):(L.DomUtil.addClass(t,"disabled"),i._updateOpacity(n,0))});var o=L.DomUtil.create("span","opacity-slider",e);L.DomUtil.create("span","slider-label",o).innerHTML="Transparency:",L.DomUtil.create("i",this.options.visibleIcon,o);var r=L.DomUtil.create("input",null,o);r.type="range",r.min=0,r.max=1,r.step=.1,r.onchange=function(e){var t=1-e.target.value||0;i._updateOpacity(n,t),l.dataset.visibileOpacity=t,L.DomUtil.removeClass(l,"disabled")},r.value=1-a,L.DomUtil.create("i",this.options.hiddenIcon,o),this._map.on("layeradd",function(t){t.layer===n&&(i._activeLayers+=1,e.style.display="",i._checkVisibility())}).on("layerremove",function(t){t.layer===n&&(i._activeLayers-=1,e.style.display="none",i._checkVisibility())})},_checkVisibility:function(){this._alwaysShow||this._activeLayers?this._container.style.display="":this._container.style.display="none"}}),L.control.htmllegend=function(e){return new L.Control.HtmlLegend(e)}}]); //# sourceMappingURL=L.Control.HtmlLegend.js.map \ No newline at end of file diff --git a/dist/L.Control.HtmlLegend.js.map b/dist/L.Control.HtmlLegend.js.map index a16138d..c362948 100644 --- a/dist/L.Control.HtmlLegend.js.map +++ b/dist/L.Control.HtmlLegend.js.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///L.Control.HtmlLegend.js","webpack:///webpack/bootstrap c972507638fabd6cb508","webpack:///./src/L.Control.HtmlLegend.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_slicedToArray","sliceIterator","arr","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","push","value","length","err","Array","isArray","TypeError","L","Control","HtmlLegend","extend","_map","_activeLayers","_alwaysShow","options","position","legends","collapseSimple","detectStretched","collapsedOnInit","defaultOpacity","visibleIcon","hiddenIcon","toggleIcon","onAdd","map","this","_container","DomUtil","create","DomEvent","disableClickPropagation","disableScrollPropagation","render","empty","forEach","_renderLegend","_checkVisibility","addLegend","legend","_this","elements","className","label","block","_addElement","html","style","_connectLayer","header","innerHTML","addClass","on","hasClass","removeClass","elementContainer","element","container","row","symbol","entries","_ref","_ref2","k","v","_updateOpacity","layer","opacity","setOpacity","setStyle","_this2","hasLayer","display","classList","add","toggleButton","dataset","visibileOpacity","e","button","target","opacityController","opacitySlider","type","min","max","step","onchange","newOpacity","control","htmllegend"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA4BAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,SAAAP,EAAAQ,EAAAC,GACAZ,EAAAa,EAAAV,EAAAQ,IACAG,OAAAC,eAAAZ,EAAAQ,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAf,GACA,GAAAQ,GAAAR,KAAAgB,WACA,WAA2B,MAAAhB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADA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file":"L.Control.HtmlLegend.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nL.Control.HtmlLegend = L.Control.extend({\n _map: null,\n _activeLayers: 0,\n _alwaysShow: false,\n options: {\n position: 'topright',\n\n // array of legend entries - see README for format\n legends: [],\n\n // if true, legend entries that are from a simple renderer will use compact presentation\n collapseSimple: false,\n\n // if true, will test to see if legend entries look stretched; these are usually in sets of 3 with the middle element having no label\n detectStretched: false,\n\n // if true, legends will be collapsed when a new instance is initialized\n collapsedOnInit: false,\n\n defaultOpacity: 1,\n visibleIcon: 'leaflet-html-legend-icon-eye',\n hiddenIcon: 'leaflet-html-legend-icon-eye-slash',\n toggleIcon: 'leaflet-html-legend-icon-eye'\n },\n\n onAdd: function onAdd(map) {\n this._map = map;\n this._container = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-html-legend');\n\n // Disable events on container\n L.DomEvent.disableClickPropagation(this._container);\n L.DomEvent.disableScrollPropagation(this._container);\n\n this.render();\n\n return this._container;\n },\n render: function render() {\n L.DomUtil.empty(this._container);\n\n this.options.legends.forEach(this._renderLegend, this);\n\n this._checkVisibility();\n },\n addLegend: function addLegend(legend) {\n this.options.legends.push(legend);\n if (this._map) {\n this._renderLegend(legend);\n }\n },\n _renderLegend: function _renderLegend(legend) {\n var _this = this;\n\n if (!legend.elements) {\n return;\n }\n\n var elements = legend.elements;\n\n var className = 'legend-block';\n\n if (this.options.detectStretched) {\n if (elements.length === 3 && elements[0].label !== '' && elements[1].label === '' && elements[2].label !== '') {\n className += ' legend-stretched';\n }\n }\n\n var block = L.DomUtil.create('div', className, this._container);\n\n if (this.options.collapseSimple && elements.length === 1 && !elements[0].label) {\n this._addElement(elements[0].html, legend.name, elements[0].style, block);\n this._connectLayer(block, legend);\n return;\n }\n\n if (legend.name) {\n var header = L.DomUtil.create('h4', null, block);\n L.DomUtil.create('div', 'legend-caret', header);\n L.DomUtil.create('span', null, header).innerHTML = legend.name;\n\n if (this.options.collapsedOnInit) {\n L.DomUtil.addClass(header, 'closed');\n }\n\n L.DomEvent.on(header, 'click', function () {\n if (L.DomUtil.hasClass(header, 'closed')) {\n L.DomUtil.removeClass(header, 'closed');\n } else {\n L.DomUtil.addClass(header, 'closed');\n }\n }, this);\n }\n\n var elementContainer = L.DomUtil.create('div', 'legend-elements', block);\n\n elements.forEach(function (element) {\n _this._addElement(element.html, element.label, element.style, elementContainer);\n }, this);\n\n this._connectLayer(block, legend);\n },\n _addElement: function _addElement(html, label, style, container) {\n var row = L.DomUtil.create('div', 'legend-row', container);\n var symbol = L.DomUtil.create('span', 'symbol', row);\n if (style) {\n Object.entries(style).forEach(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n k = _ref2[0],\n v = _ref2[1];\n\n symbol.style[k] = v;\n });\n }\n symbol.innerHTML = html;\n if (label) {\n L.DomUtil.create('label', null, row).innerHTML = label;\n }\n },\n _updateOpacity: function _updateOpacity(layer, opacity) {\n if (typeof layer.setOpacity === 'function') {\n layer.setOpacity(opacity);\n } else if (typeof layer.setStyle === 'function') {\n layer.setStyle({ opacity: opacity });\n }\n },\n _connectLayer: function _connectLayer(container, legend) {\n var _this2 = this;\n\n var layer = legend.layer;\n\n if (!layer) {\n this._alwaysShow = true;\n return;\n }\n\n var opacity = layer.opacity || this.options.defaultOpacity || 1;\n this._updateOpacity(layer, opacity);\n\n if (this._map.hasLayer(layer)) {\n this._activeLayers += 1;\n } else {\n container.style.display = 'none';\n }\n\n container.classList.add('layer-control');\n\n var toggleButton = L.DomUtil.create('i', 'visibility-toggle ' + this.options.toggleIcon, container);\n toggleButton.dataset.visibileOpacity = opacity;\n L.DomEvent.on(toggleButton, 'click', function (e) {\n var button = e.target;\n if (L.DomUtil.hasClass(button, 'disabled')) {\n L.DomUtil.removeClass(button, 'disabled');\n _this2._updateOpacity(layer, button.dataset.visibileOpacity);\n } else {\n L.DomUtil.addClass(button, 'disabled');\n _this2._updateOpacity(layer, 0);\n }\n });\n\n var opacityController = L.DomUtil.create('span', 'opacity-slider', container);\n\n L.DomUtil.create('span', 'slider-label', opacityController).innerHTML = 'Transparency:';\n\n L.DomUtil.create('i', this.options.visibleIcon, opacityController);\n\n var opacitySlider = L.DomUtil.create('input', null, opacityController);\n opacitySlider.type = 'range';\n opacitySlider.min = 0;\n opacitySlider.max = 1;\n opacitySlider.step = 0.1;\n opacitySlider.onchange = function (e) {\n var newOpacity = 1 - e.target.value || 0;\n _this2._updateOpacity(layer, newOpacity);\n toggleButton.dataset.visibileOpacity = newOpacity;\n L.DomUtil.removeClass(toggleButton, 'disabled');\n };\n opacitySlider.value = 1 - opacity;\n\n L.DomUtil.create('i', this.options.hiddenIcon, opacityController);\n\n this._map.on('layeradd', function (e) {\n if (e.layer === layer) {\n _this2._activeLayers += 1;\n container.style.display = '';\n _this2._checkVisibility();\n }\n }).on('layerremove', function (e) {\n if (e.layer === layer) {\n _this2._activeLayers -= 1;\n container.style.display = 'none';\n _this2._checkVisibility();\n }\n });\n },\n _checkVisibility: function _checkVisibility() {\n if (this._alwaysShow || this._activeLayers) {\n this._container.style.display = '';\n } else {\n this._container.style.display = 'none';\n }\n }\n});\n\nL.control.htmllegend = function (options) {\n return new L.Control.HtmlLegend(options);\n};\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// L.Control.HtmlLegend.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c972507638fabd6cb508","L.Control.HtmlLegend = L.Control.extend({\n _map: null,\n _activeLayers: 0,\n _alwaysShow: false,\n options: {\n position: 'topright',\n\n // array of legend entries - see README for format\n legends: [],\n\n // if true, legend entries that are from a simple renderer will use compact presentation\n collapseSimple: false,\n\n // if true, will test to see if legend entries look stretched; these are usually in sets of 3 with the middle element having no label\n detectStretched: false,\n\n // if true, legends will be collapsed when a new instance is initialized\n collapsedOnInit: false,\n\n defaultOpacity: 1,\n visibleIcon: 'leaflet-html-legend-icon-eye',\n hiddenIcon: 'leaflet-html-legend-icon-eye-slash',\n toggleIcon: 'leaflet-html-legend-icon-eye'\n },\n\n onAdd(map) {\n this._map = map;\n this._container = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-html-legend');\n\n // Disable events on container\n L.DomEvent.disableClickPropagation(this._container);\n L.DomEvent.disableScrollPropagation(this._container);\n\n this.render();\n\n return this._container;\n },\n\n render() {\n L.DomUtil.empty(this._container);\n\n this.options.legends.forEach(this._renderLegend, this);\n\n this._checkVisibility();\n },\n\n addLegend(legend) {\n this.options.legends.push(legend);\n if (this._map) {\n this._renderLegend(legend);\n }\n },\n\n _renderLegend(legend) {\n if (!legend.elements) {\n return;\n }\n\n const elements = legend.elements;\n\n let className = 'legend-block';\n\n if (this.options.detectStretched) {\n if (\n elements.length === 3 &&\n elements[0].label !== '' &&\n elements[1].label === '' &&\n elements[2].label !== ''\n ) {\n className += ' legend-stretched';\n }\n }\n\n const block = L.DomUtil.create('div', className, this._container);\n\n if (this.options.collapseSimple && elements.length === 1 && !elements[0].label) {\n this._addElement(elements[0].html, legend.name, elements[0].style, block);\n this._connectLayer(block, legend);\n return;\n }\n\n if (legend.name) {\n const header = L.DomUtil.create('h4', null, block);\n L.DomUtil.create('div', 'legend-caret', header);\n L.DomUtil.create('span', null, header).innerHTML = legend.name;\n\n if (this.options.collapsedOnInit) {\n L.DomUtil.addClass(header, 'closed');\n }\n\n L.DomEvent.on(header, 'click', () => {\n if (L.DomUtil.hasClass(header, 'closed')) {\n L.DomUtil.removeClass(header, 'closed');\n }\n else {\n L.DomUtil.addClass(header, 'closed');\n }\n }, this);\n }\n\n const elementContainer = L.DomUtil.create('div', 'legend-elements', block);\n\n elements.forEach((element) => {\n this._addElement(element.html, element.label, element.style, elementContainer);\n }, this);\n\n this._connectLayer(block, legend);\n },\n\n _addElement(html, label, style, container) {\n const row = L.DomUtil.create('div', 'legend-row', container);\n const symbol = L.DomUtil.create('span', 'symbol', row);\n if (style) {\n Object.entries(style).forEach(([k, v]) => { symbol.style[k] = v; });\n }\n symbol.innerHTML = html;\n if (label) {\n L.DomUtil.create('label', null, row).innerHTML = label;\n }\n },\n\n _updateOpacity(layer, opacity) {\n if (typeof layer.setOpacity === 'function') {\n layer.setOpacity(opacity);\n }\n else if (typeof layer.setStyle === 'function') {\n layer.setStyle({ opacity });\n }\n },\n\n _connectLayer(container, legend) {\n const layer = legend.layer;\n\n if (!layer) {\n this._alwaysShow = true;\n return;\n }\n\n const opacity = layer.opacity || this.options.defaultOpacity || 1;\n this._updateOpacity(layer, opacity);\n\n if (this._map.hasLayer(layer)) {\n this._activeLayers += 1;\n }\n else {\n container.style.display = 'none';\n }\n\n container.classList.add('layer-control');\n\n const toggleButton = L.DomUtil.create('i', `visibility-toggle ${this.options.toggleIcon}`, container);\n toggleButton.dataset.visibileOpacity = opacity;\n L.DomEvent.on(toggleButton, 'click', (e) => {\n const button = e.target;\n if (L.DomUtil.hasClass(button, 'disabled')) {\n L.DomUtil.removeClass(button, 'disabled');\n this._updateOpacity(layer, button.dataset.visibileOpacity);\n }\n else {\n L.DomUtil.addClass(button, 'disabled');\n this._updateOpacity(layer, 0);\n }\n });\n\n const opacityController = L.DomUtil.create('span', 'opacity-slider', container);\n\n L.DomUtil.create('span', 'slider-label', opacityController).innerHTML = 'Transparency:';\n\n L.DomUtil.create('i', this.options.visibleIcon, opacityController);\n\n const opacitySlider = L.DomUtil.create('input', null, opacityController);\n opacitySlider.type = 'range';\n opacitySlider.min = 0;\n opacitySlider.max = 1;\n opacitySlider.step = 0.1;\n opacitySlider.onchange = ((e) => {\n const newOpacity = 1 - e.target.value || 0;\n this._updateOpacity(layer, newOpacity);\n toggleButton.dataset.visibileOpacity = newOpacity;\n L.DomUtil.removeClass(toggleButton, 'disabled');\n });\n opacitySlider.value = 1 - (opacity);\n\n L.DomUtil.create('i', this.options.hiddenIcon, opacityController);\n\n this._map.on('layeradd', (e) => {\n if (e.layer === layer) {\n this._activeLayers += 1;\n container.style.display = '';\n this._checkVisibility();\n }\n }).on('layerremove', (e) => {\n if (e.layer === layer) {\n this._activeLayers -= 1;\n container.style.display = 'none';\n this._checkVisibility();\n }\n });\n },\n\n _checkVisibility() {\n if (this._alwaysShow || this._activeLayers) {\n this._container.style.display = '';\n }\n else {\n this._container.style.display = 'none';\n }\n }\n});\n\nL.control.htmllegend = options => new L.Control.HtmlLegend(options);\n\n\n\n// WEBPACK FOOTER //\n// ./src/L.Control.HtmlLegend.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///L.Control.HtmlLegend.js","webpack:///webpack/bootstrap c8cc31aa518badf77e48","webpack:///./src/L.Control.HtmlLegend.js"],"names":["modules","__webpack_require__","moduleId","installedModules","exports","module","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_slicedToArray","sliceIterator","arr","_arr","_n","_d","_e","undefined","_s","_i","Symbol","iterator","next","done","push","value","length","err","Array","isArray","TypeError","L","Control","HtmlLegend","extend","_map","_activeLayers","_alwaysShow","options","position","legends","collapseSimple","detectStretched","collapsedOnInit","updateOpacity","defaultOpacity","visibleIcon","hiddenIcon","toggleIcon","onAdd","map","this","_container","DomUtil","create","DomEvent","disableClickPropagation","disableScrollPropagation","render","empty","forEach","_renderLegend","_checkVisibility","addLegend","legend","_this","elements","className","label","block","_addElement","html","style","_connectLayer","header","innerHTML","addClass","on","hasClass","removeClass","elementContainer","element","container","row","symbol","entries","_ref","_ref2","k","v","_updateOpacity","layer","opacity","setOpacity","setStyle","_this2","hasLayer","display","classList","add","toggleButton","dataset","visibileOpacity","e","button","target","opacityController","opacitySlider","type","min","max","step","onchange","newOpacity","control","htmllegend"],"mappings":"CAAS,SAAUA,GCInB,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAE,OAGA,IAAAC,GAAAF,EAAAD,IACAI,EAAAJ,EACAK,GAAA,EACAH,WAUA,OANAJ,GAAAE,GAAAM,KAAAH,EAAAD,QAAAC,IAAAD,QAAAH,GAGAI,EAAAE,GAAA,EAGAF,EAAAD,QAvBA,GAAAD,KA4BAF,GAAAQ,EAAAT,EAGAC,EAAAS,EAAAP,EAGAF,EAAAU,EAAA,SAAAP,EAAAQ,EAAAC,GACAZ,EAAAa,EAAAV,EAAAQ,IACAG,OAAAC,eAAAZ,EAAAQ,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAZ,EAAAmB,EAAA,SAAAf,GACA,GAAAQ,GAAAR,KAAAgB,WACA,WAA2B,MAAAhB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAJ,GAAAU,EAAAE,EAAA,IAAAA,GACAA,GAIAZ,EAAAa,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAjB,KAAAc,EAAAC,IAGtDtB,EAAAyB,EAAA,GAGAzB,IAAA0B,EAAA,KDMM,SAAUtB,EAAQD,EAASH,GAEjC,YAGA,IAAI2B,GAAiB,WAAc,QAASC,GAAcC,EAAKxB,GAAK,GAAIyB,MAAeC,GAAK,EAAUC,GAAK,EAAWC,MAAKC,EAAW,KAAM,IAAK,GAAiCC,GAA7BC,EAAKP,EAAIQ,OAAOC,cAAmBP,GAAMI,EAAKC,EAAGG,QAAQC,QAAoBV,EAAKW,KAAKN,EAAGO,QAAYrC,GAAKyB,EAAKa,SAAWtC,GAA3D0B,GAAK,IAAoE,MAAOa,GAAOZ,GAAK,EAAMC,EAAKW,EAAO,QAAU,KAAW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AM,EACpBH,EAAcI,KAAO,GACrBJ,EAAcK,SAAY,SAACT,GACvB,GAAMU,GAAa,EAAIV,EAAEE,OAAOhF,OAAS,CACzCsE,GAAKL,eAAeC,EAAOsB,GAC3Bb,EAAaC,QAAQC,gBAAkBW,EACvClF,EAAEsB,QAAQ0B,YAAYqB,EAAc,aAExCO,EAAclF,MAAQ,EAAKmE,EAE3B7D,EAAEsB,QAAQC,OAAO,IAAKH,KAAKb,QAAQS,WAAY2D,GAE/CvD,KAAKhB,KAAK0C,GAAG,WAAY,SAAC0B,GAClBA,EAAEZ,QAAUA,IACZI,EAAK3D,eAAiB,EACtB8C,EAAUV,MAAMyB,QAAU,GAC1BF,EAAKjC,sBAEVe,GAAG,cAAe,SAAC0B,GACdA,EAAEZ,QAAUA,IACZI,EAAK3D,eAAiB,EACtB8C,EAAUV,MAAMyB,QAAU,OAC1BF,EAAKjC,uBAKjBA,iBA1MoC,WA2M5BX,KAAKd,aAAec,KAAKf,cACzBe,KAAKC,WAAWoB,MAAMyB,QAAU,GAGhC9C,KAAKC,WAAWoB,MAAMyB,QAAU,UAK5ClE,EAAEmF,QAAQC,WAAa,SAAA7E,GAAA,MAAW,IAAIP,GAAEC,QAAQC,WAAWK","file":"L.Control.HtmlLegend.js","sourcesContent":["/******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 0);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\n\nL.Control.HtmlLegend = L.Control.extend({\n _map: null,\n _activeLayers: 0,\n _alwaysShow: false,\n options: {\n position: 'topright',\n\n // array of legend entries - see README for format\n legends: [],\n\n // if true, legend entries that are from a simple renderer will use compact presentation\n collapseSimple: false,\n\n // if true, will test to see if legend entries look stretched; these are usually in sets of 3 with the middle element having no label\n detectStretched: false,\n\n // if true, legends will be collapsed when a new instance is initialized\n collapsedOnInit: false,\n\n updateOpacity: null,\n defaultOpacity: 1,\n visibleIcon: 'leaflet-html-legend-icon-eye',\n hiddenIcon: 'leaflet-html-legend-icon-eye-slash',\n toggleIcon: 'leaflet-html-legend-icon-eye'\n },\n\n onAdd: function onAdd(map) {\n this._map = map;\n this._container = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-html-legend');\n\n // Disable events on container\n L.DomEvent.disableClickPropagation(this._container);\n L.DomEvent.disableScrollPropagation(this._container);\n\n this.render();\n\n return this._container;\n },\n render: function render() {\n L.DomUtil.empty(this._container);\n\n this.options.legends.forEach(this._renderLegend, this);\n\n this._checkVisibility();\n },\n addLegend: function addLegend(legend) {\n this.options.legends.push(legend);\n if (this._map) {\n this._renderLegend(legend);\n }\n },\n _renderLegend: function _renderLegend(legend) {\n var _this = this;\n\n if (!legend.elements) {\n return;\n }\n\n var elements = legend.elements;\n\n var className = 'legend-block';\n\n if (this.options.detectStretched) {\n if (elements.length === 3 && elements[0].label !== '' && elements[1].label === '' && elements[2].label !== '') {\n className += ' legend-stretched';\n }\n }\n\n var block = L.DomUtil.create('div', className, this._container);\n\n if (this.options.collapseSimple && elements.length === 1 && !elements[0].label) {\n this._addElement(elements[0].html, legend.name, elements[0].style, block);\n this._connectLayer(block, legend);\n return;\n }\n\n if (legend.name) {\n var header = L.DomUtil.create('h4', null, block);\n L.DomUtil.create('div', 'legend-caret', header);\n L.DomUtil.create('span', null, header).innerHTML = legend.name;\n\n if (this.options.collapsedOnInit) {\n L.DomUtil.addClass(header, 'closed');\n }\n\n L.DomEvent.on(header, 'click', function () {\n if (L.DomUtil.hasClass(header, 'closed')) {\n L.DomUtil.removeClass(header, 'closed');\n } else {\n L.DomUtil.addClass(header, 'closed');\n }\n }, this);\n }\n\n var elementContainer = L.DomUtil.create('div', 'legend-elements', block);\n\n elements.forEach(function (element) {\n _this._addElement(element.html, element.label, element.style, elementContainer);\n }, this);\n\n this._connectLayer(block, legend);\n },\n _addElement: function _addElement(html, label, style, container) {\n var row = L.DomUtil.create('div', 'legend-row', container);\n var symbol = L.DomUtil.create('span', 'symbol', row);\n if (style) {\n Object.entries(style).forEach(function (_ref) {\n var _ref2 = _slicedToArray(_ref, 2),\n k = _ref2[0],\n v = _ref2[1];\n\n symbol.style[k] = v;\n });\n }\n symbol.innerHTML = html;\n if (label) {\n L.DomUtil.create('label', null, row).innerHTML = label;\n }\n },\n _updateOpacity: function _updateOpacity(layer, opacity) {\n if (typeof this.options.updateOpacity === 'function') {\n this.options.updateOpacity(layer, opacity);\n } else if (typeof layer.setOpacity === 'function') {\n layer.setOpacity(opacity);\n } else if (typeof layer.setStyle === 'function') {\n layer.setStyle({ opacity: opacity });\n }\n },\n _connectLayer: function _connectLayer(container, legend) {\n var _this2 = this;\n\n var layer = legend.layer;\n\n if (!layer) {\n this._alwaysShow = true;\n return;\n }\n\n var opacity = layer.opacity || this.options.defaultOpacity || 1;\n this._updateOpacity(layer, opacity);\n\n if (this._map.hasLayer(layer)) {\n this._activeLayers += 1;\n } else {\n container.style.display = 'none';\n }\n\n container.classList.add('layer-control');\n\n var toggleButton = L.DomUtil.create('i', 'visibility-toggle ' + this.options.toggleIcon, container);\n toggleButton.dataset.visibileOpacity = opacity;\n L.DomEvent.on(toggleButton, 'click', function (e) {\n var button = e.target;\n if (L.DomUtil.hasClass(button, 'disabled')) {\n L.DomUtil.removeClass(button, 'disabled');\n _this2._updateOpacity(layer, button.dataset.visibileOpacity);\n } else {\n L.DomUtil.addClass(button, 'disabled');\n _this2._updateOpacity(layer, 0);\n }\n });\n\n var opacityController = L.DomUtil.create('span', 'opacity-slider', container);\n\n L.DomUtil.create('span', 'slider-label', opacityController).innerHTML = 'Transparency:';\n\n L.DomUtil.create('i', this.options.visibleIcon, opacityController);\n\n var opacitySlider = L.DomUtil.create('input', null, opacityController);\n opacitySlider.type = 'range';\n opacitySlider.min = 0;\n opacitySlider.max = 1;\n opacitySlider.step = 0.1;\n opacitySlider.onchange = function (e) {\n var newOpacity = 1 - e.target.value || 0;\n _this2._updateOpacity(layer, newOpacity);\n toggleButton.dataset.visibileOpacity = newOpacity;\n L.DomUtil.removeClass(toggleButton, 'disabled');\n };\n opacitySlider.value = 1 - opacity;\n\n L.DomUtil.create('i', this.options.hiddenIcon, opacityController);\n\n this._map.on('layeradd', function (e) {\n if (e.layer === layer) {\n _this2._activeLayers += 1;\n container.style.display = '';\n _this2._checkVisibility();\n }\n }).on('layerremove', function (e) {\n if (e.layer === layer) {\n _this2._activeLayers -= 1;\n container.style.display = 'none';\n _this2._checkVisibility();\n }\n });\n },\n _checkVisibility: function _checkVisibility() {\n if (this._alwaysShow || this._activeLayers) {\n this._container.style.display = '';\n } else {\n this._container.style.display = 'none';\n }\n }\n});\n\nL.control.htmllegend = function (options) {\n return new L.Control.HtmlLegend(options);\n};\n\n/***/ })\n/******/ ]);\n\n\n// WEBPACK FOOTER //\n// L.Control.HtmlLegend.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c8cc31aa518badf77e48","L.Control.HtmlLegend = L.Control.extend({\n _map: null,\n _activeLayers: 0,\n _alwaysShow: false,\n options: {\n position: 'topright',\n\n // array of legend entries - see README for format\n legends: [],\n\n // if true, legend entries that are from a simple renderer will use compact presentation\n collapseSimple: false,\n\n // if true, will test to see if legend entries look stretched; these are usually in sets of 3 with the middle element having no label\n detectStretched: false,\n\n // if true, legends will be collapsed when a new instance is initialized\n collapsedOnInit: false,\n\n updateOpacity: null,\n defaultOpacity: 1,\n visibleIcon: 'leaflet-html-legend-icon-eye',\n hiddenIcon: 'leaflet-html-legend-icon-eye-slash',\n toggleIcon: 'leaflet-html-legend-icon-eye'\n },\n\n onAdd(map) {\n this._map = map;\n this._container = L.DomUtil.create('div', 'leaflet-control leaflet-bar leaflet-html-legend');\n\n // Disable events on container\n L.DomEvent.disableClickPropagation(this._container);\n L.DomEvent.disableScrollPropagation(this._container);\n\n this.render();\n\n return this._container;\n },\n\n render() {\n L.DomUtil.empty(this._container);\n\n this.options.legends.forEach(this._renderLegend, this);\n\n this._checkVisibility();\n },\n\n addLegend(legend) {\n this.options.legends.push(legend);\n if (this._map) {\n this._renderLegend(legend);\n }\n },\n\n _renderLegend(legend) {\n if (!legend.elements) {\n return;\n }\n\n const elements = legend.elements;\n\n let className = 'legend-block';\n\n if (this.options.detectStretched) {\n if (\n elements.length === 3 &&\n elements[0].label !== '' &&\n elements[1].label === '' &&\n elements[2].label !== ''\n ) {\n className += ' legend-stretched';\n }\n }\n\n const block = L.DomUtil.create('div', className, this._container);\n\n if (this.options.collapseSimple && elements.length === 1 && !elements[0].label) {\n this._addElement(elements[0].html, legend.name, elements[0].style, block);\n this._connectLayer(block, legend);\n return;\n }\n\n if (legend.name) {\n const header = L.DomUtil.create('h4', null, block);\n L.DomUtil.create('div', 'legend-caret', header);\n L.DomUtil.create('span', null, header).innerHTML = legend.name;\n\n if (this.options.collapsedOnInit) {\n L.DomUtil.addClass(header, 'closed');\n }\n\n L.DomEvent.on(header, 'click', () => {\n if (L.DomUtil.hasClass(header, 'closed')) {\n L.DomUtil.removeClass(header, 'closed');\n }\n else {\n L.DomUtil.addClass(header, 'closed');\n }\n }, this);\n }\n\n const elementContainer = L.DomUtil.create('div', 'legend-elements', block);\n\n elements.forEach((element) => {\n this._addElement(element.html, element.label, element.style, elementContainer);\n }, this);\n\n this._connectLayer(block, legend);\n },\n\n _addElement(html, label, style, container) {\n const row = L.DomUtil.create('div', 'legend-row', container);\n const symbol = L.DomUtil.create('span', 'symbol', row);\n if (style) {\n Object.entries(style).forEach(([k, v]) => { symbol.style[k] = v; });\n }\n symbol.innerHTML = html;\n if (label) {\n L.DomUtil.create('label', null, row).innerHTML = label;\n }\n },\n\n _updateOpacity(layer, opacity) {\n if (typeof this.options.updateOpacity === 'function') {\n this.options.updateOpacity(layer, opacity)\n } else if (typeof layer.setOpacity === 'function') {\n layer.setOpacity(opacity);\n } else if (typeof layer.setStyle === 'function') {\n layer.setStyle({ opacity });\n }\n },\n\n _connectLayer(container, legend) {\n const layer = legend.layer;\n\n if (!layer) {\n this._alwaysShow = true;\n return;\n }\n\n const opacity = layer.opacity || this.options.defaultOpacity || 1;\n this._updateOpacity(layer, opacity);\n\n if (this._map.hasLayer(layer)) {\n this._activeLayers += 1;\n }\n else {\n container.style.display = 'none';\n }\n\n container.classList.add('layer-control');\n\n const toggleButton = L.DomUtil.create('i', `visibility-toggle ${this.options.toggleIcon}`, container);\n toggleButton.dataset.visibileOpacity = opacity;\n L.DomEvent.on(toggleButton, 'click', (e) => {\n const button = e.target;\n if (L.DomUtil.hasClass(button, 'disabled')) {\n L.DomUtil.removeClass(button, 'disabled');\n this._updateOpacity(layer, button.dataset.visibileOpacity);\n }\n else {\n L.DomUtil.addClass(button, 'disabled');\n this._updateOpacity(layer, 0);\n }\n });\n\n const opacityController = L.DomUtil.create('span', 'opacity-slider', container);\n\n L.DomUtil.create('span', 'slider-label', opacityController).innerHTML = 'Transparency:';\n\n L.DomUtil.create('i', this.options.visibleIcon, opacityController);\n\n const opacitySlider = L.DomUtil.create('input', null, opacityController);\n opacitySlider.type = 'range';\n opacitySlider.min = 0;\n opacitySlider.max = 1;\n opacitySlider.step = 0.1;\n opacitySlider.onchange = ((e) => {\n const newOpacity = 1 - e.target.value || 0;\n this._updateOpacity(layer, newOpacity);\n toggleButton.dataset.visibileOpacity = newOpacity;\n L.DomUtil.removeClass(toggleButton, 'disabled');\n });\n opacitySlider.value = 1 - (opacity);\n\n L.DomUtil.create('i', this.options.hiddenIcon, opacityController);\n\n this._map.on('layeradd', (e) => {\n if (e.layer === layer) {\n this._activeLayers += 1;\n container.style.display = '';\n this._checkVisibility();\n }\n }).on('layerremove', (e) => {\n if (e.layer === layer) {\n this._activeLayers -= 1;\n container.style.display = 'none';\n this._checkVisibility();\n }\n });\n },\n\n _checkVisibility() {\n if (this._alwaysShow || this._activeLayers) {\n this._container.style.display = '';\n }\n else {\n this._container.style.display = 'none';\n }\n }\n});\n\nL.control.htmllegend = options => new L.Control.HtmlLegend(options);\n\n\n\n// WEBPACK FOOTER //\n// ./src/L.Control.HtmlLegend.js"],"sourceRoot":""} \ No newline at end of file diff --git a/index.html b/index.html index e9b2bf3..8971a3b 100644 --- a/index.html +++ b/index.html @@ -36,6 +36,34 @@ .icon-eye:before { content: "\e904"; } + + .hexagon { + position: relative; + width: 13px; + height: 7.51px; + background-color: #64C7CC; + margin: 3.75px 0; + } + + .hexagon:before, + .hexagon:after { + content: ""; + position: absolute; + width: 0; + border-left: 6.5px solid transparent; + border-right: 6.5px solid transparent; + } + + .hexagon:before { + bottom: 100%; + border-bottom: 3.75px solid #64C7CC; + } + + .hexagon:after { + top: 100%; + width: 0; + border-top: 3.75px solid #64C7CC; + } @@ -56,14 +84,14 @@ diff --git a/package.json b/package.json index 89b033b..22766cd 100644 --- a/package.json +++ b/package.json @@ -1,29 +1,29 @@ { "name": "leaflet-html-legend", - "version": "0.3.0", + "version": "0.4.0", "description": "Leaflet legend plugin using html elements", "homepage": "http://github.com/consbio/Leaflet.HtmlLegend", "author": { "name": "Kaveh Karimi", - "email": "kaveh.ka@consbio.org" + "email": "kaveh@consbio.org" }, "scripts": { "build": "webpack --config webpack.config.js" }, "devDependencies": { - "babel-core": "^6.26.0", - "babel-loader": "^7.1.2", - "babel-preset-es2015": "^6.24.1", - "css-loader": "^0.28.7", - "extract-text-webpack-plugin": "^3.0.2", - "style-loader": "^0.19.0", - "webpack": "^3.8.1" + "babel-core": "^6.26.*", + "babel-loader": "^7.1.*", + "babel-preset-es2015": "^6.24.*", + "css-loader": "^0.28.*", + "extract-text-webpack-plugin": "^3.0.*", + "style-loader": "^0.19.*", + "webpack": "^3.8.*" }, "bugs": { "url": "https://github.com/consbio/Leaflet.HtmlLegend/issues" }, "peerDependencies": { - "leaflet": "^1.2.0" + "leaflet": "^1.3.*" }, "main": "dist/L.Control.HtmlLegend.js", "repository": { diff --git a/src/L.Control.HtmlLegend.js b/src/L.Control.HtmlLegend.js index 82932db..29b09e6 100755 --- a/src/L.Control.HtmlLegend.js +++ b/src/L.Control.HtmlLegend.js @@ -17,6 +17,7 @@ L.Control.HtmlLegend = L.Control.extend({ // if true, legends will be collapsed when a new instance is initialized collapsedOnInit: false, + updateOpacity: null, defaultOpacity: 1, visibleIcon: 'leaflet-html-legend-icon-eye', hiddenIcon: 'leaflet-html-legend-icon-eye-slash', @@ -120,10 +121,11 @@ L.Control.HtmlLegend = L.Control.extend({ }, _updateOpacity(layer, opacity) { - if (typeof layer.setOpacity === 'function') { + if (typeof this.options.updateOpacity === 'function') { + this.options.updateOpacity(layer, opacity) + } else if (typeof layer.setOpacity === 'function') { layer.setOpacity(opacity); - } - else if (typeof layer.setStyle === 'function') { + } else if (typeof layer.setStyle === 'function') { layer.setStyle({ opacity }); } },