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eAAe,EAAI,KAAK,eAAe,EAAI,KAAK,0HACd,EAAI,+CAE7E,KAAK,WAAW,YAAY,EAChC,EAEA,cAAe,SAAS,GACpB,IAAI,EAAc,EAAE,QAAQ,OAAO,MAAO,wBAC1C,EAAY,UAAY,mDAAmD,EAAI,KAAK,cAAc,EAAI,KAAK,mBAAmB,EAAI,yEACnF,EAAI,YACnD,KAAK,aAAa,YAAY,EAClC,EAEA,eAAgB,SAAS,GAErB,SAAS,eAAe,GAAI,aAAa,QAAS,gBAEtD,EAEA,eAAgB,SAAS,GAErB,SAAS,eAAe,GAAI,aAAa,QAAS,gBACtD,EAEA,iBAAkB,SAAS,GAEvB,IAAI,EAAS,SAAS,eAAe,GACvB,OAAX,GACH,EAAO,WAAW,YAAY,EAClC,EAEA,mBAAoB,SAAS,GAEzB,IAAI,EAAW,SAAS,eAAe,GACvB,OAAb,GACH,EAAS,WAAW,YAAY,EACpC,EAEA,aAAc,WACV,MAA8B,KAA3B,KAAK,QAAQ,SAKpB,EAEA,iBAAkB,WACd,KAAK,QAAQ,UAAY,EAC7B,EAEA,gBAAiB,WACb,KAAK,QAAQ,MAAM,QAAQ,OAC3B,KAAK,eAAe,MAAM,QAAQ,OACtC,EAEA,aAAc,WACV,KAAK,QAAQ,MAAM,QAAQ,QAC3B,KAAK,eAAe,MAAM,QAAQ,MACtC","file":"/npm/leaflet-custom-legend@1.0.0/src/leaflet.setLegend.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/leaflet-custom-legend@1.0.0/src/leaflet.setLegend.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\r\n * @class LMap.setLegend\r\n * @extents {L.Control}\r\n * @param {object} options - 图例传入参数\r\n * @param {string} [options.position] - 图例控件位置\r\n * @param {string} [options.title] - 图例标题\r\n * @param {string} [options.legendType] - 图例类型\r\n * @param {array}  [options.imgArr] - 图文型图例参数（对象数组，含图片url与文字描述）\r\n * @param {array}  [options.colorArr] - 颜色型图例参数数组（对象数组，含颜色及对应文字描述）\r\n * @param {string} [options.imgId] - 所添加的img图例的唯一标识\r\n * @param {string} [options.colorId] - 所添加的color图例的唯一标识\r\n */\r\nL.Control.setLegend = L.Control.extend({\r\n    options: {\r\n        position: 'topright',\r\n        title: '图例',\r\n        legendType: '',\r\n        imgArr: [],\r\n        colorArr: [],\r\n        imgId: '',\r\n        colorId: '' \r\n    },\r\n    initialize: function(options) {\r\n        L.Util.extend(this.options, options)\r\n    },\r\n    onAdd: function(map) {\r\n        // _container为控件容器\r\n        this._container = L.DomUtil.create('div', 'leaflet-control-clegend')\r\n        this._container.setAttribute('id', 'legendContainer') // 为content设置id 方便判别时隐藏控件\r\n        \r\n        //////////////////////////////////////////////////////////////////////////////////////////////////\r\n        // 创建一个div容器包含所有的内容\r\n        this.mainDiv = L.DomUtil.create('div', 'leaflet-control-max-div')\r\n        this.mainDiv.style.display=\"block\"\r\n        // 创建title\r\n        var title = L.DomUtil.create('div', 'leaflet-control-clegend-title')\r\n        title.innerHTML = '图例'\r\n        // this._container.appendChild(title)\r\n        this.mainDiv.appendChild(title)\r\n        // 创建关闭按钮\r\n        var closeBtn = L.DomUtil.create('a', 'leaflet-control-legend-close')\r\n        // closeBtn.innerHTML = 'X'\r\n        closeBtn.innerHTML = `<img src=\"../src/assets/images/close.png\" style=\"width:18px;height:18px;\">`\r\n        title.appendChild(closeBtn)\r\n        // 注册关闭事件\r\n        L.DomEvent.on(closeBtn, 'click', this._onCloseControl, this)\r\n\r\n        // 创建legend的内容\r\n        this.setContent()\r\n\r\n        /////////////////////////////////////////////////////////////////////////////////////////////////\r\n        // 创建一个button展开隐藏的图例\r\n        this._showLegendBtn = L.DomUtil.create('select', 'show-legend-button')\r\n        this._showLegendBtn.style.display=\"none\"\r\n        this._showLegendBtn.innerHTML = '图例'\r\n        var option = L.DomUtil.create('option', '')\r\n        option.innerHTML = '图例'\r\n        this._showLegendBtn.appendChild(option)\r\n        L.DomEvent.on(this._showLegendBtn, 'click', this._showControl, this)\r\n        \r\n        // 添加button和this.mainDiv到父容器_container中\r\n        this._container.appendChild(this._showLegendBtn)\r\n        this._container.appendChild(this.mainDiv)\r\n        \r\n        return this._container\r\n    },\r\n    // 添加content\r\n    setContent: function() {\r\n        this.content = L.DomUtil.create('div', 'leaflet-control-legend-content')\r\n        this.content.setAttribute('id', 'legendMainContent') // 为content设置id 方便判别时隐藏控件\r\n        if(this.options.legendType === 'imgType') { // 图文式\r\n            this.setImgContent(this.options.title, this.options.legendType, this.options.imgArr,this.options.imgId)\r\n        }\r\n        if(this.options.legendType === 'colorType') { // 颜色渐变式\r\n            this.setColorContent(this.options.title, this.options.legendType, this.options.colorArr, this.options.colorId)\r\n        }\r\n        this.mainDiv.appendChild(this.content)\r\n    },\r\n    // 添加imgContent\r\n    /**\r\n     * \r\n     * @param {string} title - 图例标题\r\n     * @param {string} legendType - 图例类型\r\n     * @param {array} imgArr - img图例数组\r\n     * @param {string} imgId - img唯一标识 \r\n     */\r\n    setImgContent: function(title, legendType, imgArr, imgId) {\r\n        this.imgContent = L.DomUtil.create('div', 'leaflet-control-legend-imgcontent')\r\n        this.imgContent.setAttribute('id', `${imgId}`) // 为imgContent设置id 方便控制现隐\r\n        // this.setTitle(title, legendType, imgId) // 添加不同图例标题\r\n        for(let i = 0; i < imgArr.length; i++) {\r\n            this._addImgItem(imgArr[i])\r\n        }\r\n\r\n        // 判断去重\r\n        if(this.content.childNodes.length === 0) { // 还是空的图例\r\n            this.content.appendChild(this.imgContent)\r\n        } else { // 已存在一个图例\r\n            let arr = []\r\n            this.content.childNodes.forEach( item => {\r\n                arr.push(item.id)\r\n            })\r\n            if(arr.indexOf(imgId) > -1) { // 已存在相同的图例\r\n                return\r\n            } else {\r\n                this.content.appendChild(this.imgContent)\r\n            }\r\n        }\r\n    },\r\n    // 添加colorContent\r\n    /**\r\n     * \r\n     * @param {string} title - 图例标题\r\n     * @param {string} legendType - 图例类型\r\n     * @param {array} colorArr - color图例数组\r\n     * @param {string} colorId - color唯一标识 \r\n     */\r\n    setColorContent: function(title, legendType, colorArr, colorId) {\r\n        this.colorContent = L.DomUtil.create('div', 'leaflet-control-legend-colorContent')\r\n        this.colorContent.setAttribute('id', `${colorId}`) // 为colorContent设置id 方便控制现隐\r\n        this.setTitle(title, legendType, colorId)\r\n        for(let i = 0; i < colorArr.length; i++) {\r\n            this._addColorItem(colorArr[i])\r\n        }\r\n        this.content.appendChild(this.colorContent)\r\n    },\r\n    // 添加图例小标题\r\n    /**\r\n     * \r\n     * @param {string} title - 图例标题\r\n     * @param {string} legendType - 图例类型\r\n     * @param {string} id - 唯一标识id\r\n     */\r\n    setTitle: function(title, legendType, id) {\r\n        let titleContent = L.DomUtil.create('span', 'leaflet-control-legend-content-title')\r\n        if(legendType === 'imgType') {\r\n            titleContent.setAttribute('id', `${id}`)\r\n            titleContent.innerHTML = `<strong>${title}</strong>`\r\n            this.imgContent.appendChild(titleContent)\r\n        }\r\n        if(legendType === 'colorType') {\r\n            titleContent.setAttribute('id', `${id}`)\r\n            titleContent.innerHTML = `<strong>${title}</strong>`\r\n            this.colorContent.appendChild(titleContent)\r\n        }\r\n    },\r\n    // 逐行添加图文式图例\r\n    _addImgItem: function(obj) {\r\n        let imglegend = L.DomUtil.create('div', 'legend-imgitem-div')\r\n        imglegend.innerHTML = `<img src=\"${obj.url}\" width=\"${obj.size[0]}\" height=\"${obj.size[1]}\" style=\"margin:4px 15px 0 15px;\" />\r\n                               <span style=\"position:absolute;margin-top:6px;\">${obj.label}</span>\r\n                              `\r\n        this.imgContent.appendChild(imglegend) \r\n    },\r\n    // 逐行添加颜色渐变式图例\r\n    _addColorItem: function(obj) {\r\n        let colorlegend = L.DomUtil.create('div', 'legend-coloritem-div')\r\n        colorlegend.innerHTML = `<span style=\"float:left;margin-left:12px;height:${obj.size[0]}px;width:${obj.size[1]}px;background:${obj.color};\"></span>\r\n                                <p style=\"margin:0;\">${obj.label}</p>`\r\n        this.colorContent.appendChild(colorlegend)\r\n    },\r\n    // 隐藏对应的imgContent或者colorContent\r\n    hideOneContent: function(id) {\r\n        // console.log('Hide!!!')\r\n        document.getElementById(id).setAttribute('style', 'display: none')\r\n        // document.getElementById(id).style.display = 'none'\r\n    },\r\n    // 显示对应的imgContent或colorContent\r\n    showOneContent: function(id) {\r\n        // console.log('Show!!!')\r\n        document.getElementById(id).setAttribute('style', 'display:block')\r\n    },\r\n    // 移除对应的imgContent\r\n    removeImgContent: function(imgId) {\r\n        // console.log('remove imgLegend!!!')\r\n        let divobj = document.getElementById(imgId)\r\n        if(divobj === null) return\r\n        divobj.parentNode.removeChild(divobj)\r\n    },\r\n    // 移除对应的colorCotent\r\n    removeColorContent: function(colorId) {\r\n        // console.log('remove colorContent!!!')\r\n        let colorDiv = document.getElementById(colorId)\r\n        if(colorDiv === null) return\r\n        colorDiv.parentNode.removeChild(colorDiv)\r\n    },\r\n    // 判断content是否为空\r\n    judgeContent: function() {\r\n        if(this.content.innerHTML === '') {\r\n            return true\r\n        } else {\r\n            return false\r\n        }\r\n    },\r\n    // 将content里的内容置空\r\n    setContentToNULL: function() {\r\n        this.content.innerHTML = ''\r\n    },\r\n    // 隐藏图例\r\n    _onCloseControl: function () {\r\n        this.mainDiv.style.display=\"none\"\r\n        this._showLegendBtn.style.display=\"block\"\r\n    },\r\n    // 显示隐藏的图例\r\n    _showControl: function() {\r\n        this.mainDiv.style.display=\"block\"\r\n        this._showLegendBtn.style.display=\"none\"\r\n    }\r\n})"]}