Skip to content
Snippets Groups Projects
LayerLegend.js.map 22.7 KiB
Newer Older
{"version":3,"file":"LayerLegend.js","sourceRoot":"","sources":["../../src/collections/LayerLegend.ts"],"names":[],"mappings":"AAAA;;GAEG;;;AAEH,2CAAsC;AACtC,6CAAwC;AACxC,gDAA2C;AAE3C,IAAI,EAAE,GAAG,iBAAO,CAAC,aAAa,CAAC,CAAC;AAChC,0BAA6B;AAgB7B;IAiBI;;;;;;;OAOG;IACH,oBAAY,WAAyB,EAAE,MAAmB;QACtD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QAEtB,EAAE,CAAC,CAAC,OAAO,WAAW,IAAI,WAAW,CAAC,CAAC,CAAC;YACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;YACnB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;YACtB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;YACnC,IAAI,CAAC,aAAa,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;YACxB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;YACzB,IAAI,CAAC,iBAAiB,GAAG,EAAE,CAAC;YAC5B,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YACtB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QAC1B,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,IAAI,CAAC,OAAO,GAAG,kBAAQ,EAAE,CAAC;YAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,SAAS,GAAG,WAAW,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AAC;QACX,CAAC;QAED,IAAI,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;QAE7B,mDAAmD;QACnD,EAAE,CAAC,CAAE,IAAI,CAAC,YAA2B,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,OAAO,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC;YAC3F,OAAO,GAAG,EAAE,CAAC;QACjB,CAAC;QAED,EAAE,CAAC,CAAC,OAAQ,OAAuB,CAAC,SAAS,KAAK,WAAW,CAAC,CAAC,CAAC;YAC5D,IAAI,SAAS,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;YAC/B,IAAI,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;YAC5D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,CAAE,OAAuB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC7D,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ;;eAEG;YACH,IAAI,SAAS,GAAc,WAAW,CAAC,CAAC,CAAc,CAAC;YAEvD,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IACL,kBAAC;AAAD,CAAC,AA/ID,IA+IC;AA/IY,kCAAW;AAiJxB,EAAE,CAAC,WAAW,GAAG,WAAW,CAAC;AAC7B,kBAAe,WAAW,CAAC","sourcesContent":["/**\r\n * Created by gavorhes on 12/16/2015.\r\n */\r\n\r\nimport provide from '../util/provide';\r\nimport makeGuid from '../util/makeGuid';\r\nimport mapMove from '../olHelpers/mapMove';\r\n\r\nlet nm = provide('collections');\r\nimport $ = require('jquery');\r\nimport {LayerBase} from \"../layers\";\r\n\r\nexport interface iLegendItem{\r\n    groupName: string;\r\n    collapse?: boolean;\r\n    addCheck?: boolean;\r\n    items: Array<iLegendItem|LayerBase>\r\n}\r\n\r\nexport interface iLegendOptions{\r\n    layerDivClasses?: string[]\r\n    legendTitle?: string\r\n    scaleDependent?: boolean\r\n}\r\n\r\nclass LayerGroup {\r\n    groupLayers: any;\r\n    groupLayersLookup: any;\r\n    groupGroupsLookup: any;\r\n    groupGroups: any;\r\n    itemIdArray: any;\r\n    groupId: any;\r\n    groupName: any;\r\n    allLayerArray: any;\r\n    parent: any;\r\n    allGroupArray: any;\r\n    allGroupLookup: any;\r\n    allLayerLookup: any;\r\n    collapse: boolean;\r\n    addCheck: boolean;\r\n    layerParentLookup: any;\r\n\r\n    /**\r\n     *\r\n     * @param {object} [groupConfig={}] - group configuration object\r\n     * @param {string} groupConfig.groupName - the group name\r\n     * @param {boolean} [groupConfig.collapse=false] - if the group should be collapsed initially\r\n     * @param {boolean} [groupConfig.addCheck=true] - if the group should have a checkbox controlling visibility of all layers\r\n     * @param {LayerGroup} [parent=undefined] - the parent group\r\n     */\r\n    constructor(groupConfig?: iLegendItem, parent?: LayerGroup) {\r\n        this.groupLayers = [];\r\n        this.groupLayersLookup = {};\r\n        this.groupGroups = [];\r\n        this.groupGroupsLookup = {};\r\n        this.itemIdArray = [];\r\n\r\n        if (typeof groupConfig == 'undefined') {\r\n            this.parent = null;\r\n            this.groupId = 'root';\r\n            this.groupName = 'root';\r\n            this.allGroupLookup = {root: this};\r\n            this.allGroupArray = [this];\r\n            this.allLayerArray = [];\r\n            this.allLayerLookup = {};\r\n            this.layerParentLookup = {};\r\n            this.collapse = false;\r\n            this.addCheck = false;\r\n        } else {\r\n            this.groupId = makeGuid();\r\n            this.parent = parent;\r\n            this.groupName = groupConfig.groupName;\r\n            this.collapse = typeof  groupConfig.collapse == 'boolean' ? groupConfig.collapse : false;\r\n            this.addCheck = typeof  groupConfig.addCheck == 'boolean' ? groupConfig.addCheck : true;\r\n        }\r\n    }\r\n\r\n    /**\r\n     *\r\n     * @param {object} groupConfig - configuration object\r\n     * @param {string} groupConfig.groupName - the group name\r\n     * @param {boolean} groupConfig.collapse if the group should be collapsed initially\r\n     * @param {boolean} groupConfig.addCheck if the group should have a checkbox controlling visibility of all layers\r\n     * @param {Array<LayerGroup>} parents parent groups\r\n     * @returns {LayerGroup} the layer group just added\r\n     */\r\n    addGroup(groupConfig: iLegendItem, parents: string[]) {\r\n        let parent;\r\n        if (parents.length > 0) {\r\n            parent = parents[parents.length - 1];\r\n        } else {\r\n            parent = 'root';\r\n        }\r\n\r\n\r\n        /**\r\n         * @type {LayerGroup}\r\n         */\r\n        let parentGroup = this.allGroupLookup[parent];\r\n        let newGroup = new LayerGroup(groupConfig, parentGroup);\r\n        this.allGroupLookup[newGroup.groupId] = newGroup;\r\n        this.allGroupArray.push(newGroup);\r\n\r\n        parentGroup.groupGroups.push(newGroup);\r\n        parentGroup.groupGroupsLookup[newGroup.groupId] = newGroup;\r\n\r\n        if (parentGroup.itemIdArray.indexOf(newGroup.groupId) > 0) {\r\n            console.log(newGroup.groupId);\r\n            throw 'layer and group ids must be unique';\r\n        }\r\n        parentGroup.itemIdArray.push(newGroup.groupId);\r\n\r\n        return newGroup;\r\n    }\r\n\r\n    /**\r\n     *\r\n     * @param {LayerBase} newLayer the layer to be added\r\n     * @param {Array} parents array\r\n     */\r\n    addLegendLayer(newLayer: LayerBase, parents: string[]) {\r\n        let parent;\r\n        if (parents.length > 0) {\r\n            parent = parents[parents.length - 1];\r\n        } else {\r\n            parent = 'root';\r\n        }\r\n\r\n        this.allLayerLookup[newLayer.id] = newLayer;\r\n        this.allLayerArray.push(newLayer);\r\n\r\n        /**\r\n         * @type {LayerGroup}\r\n         */\r\n        let parentGroup = this.allGroupLookup[parent];\r\n\r\n        parentGroup.groupLayers.push(newLayer);\r\n        parentGroup.groupLayersLookup[newLayer.id] = newLayer;\r\n        if (parentGroup.itemIdArray.indexOf(newLayer.id) > 0) {\r\n            console.log(newLayer.id);\r\n            throw 'layer and group ids must be unique';\r\n        }\r\n        parentGroup.itemIdArray.push(newLayer.id);\r\n\r\n        this.layerParentLookup[newLayer.id] = parentGroup;\r\n\r\n    }\r\n\r\n\r\n\r\n    getLegendHtml(legendId: string, options: iLegendOptions) {\r\n\r\n\r\n        let legendHtml = `<ul id=\"${legendId}\" class=\"legend-container\">`;\r\n\r\n        legendHtml += `<li>${options.legendTitle}<input type=\"checkbox\" checked id=\"suppress-by-extent-${legendId}\" class=\"suppress-by-extent\">` +\r\n            `<label title=\"Suppress layers not visible at this zoom level\" for=\"suppress-by-extent-${legendId}\">` +\r\n            `<span></span>` +\r\n            `</label></li>`;\r\n\r\n        legendHtml += this._buildLegend(this.itemIdArray, this, options.layerDivClasses) + '</ul>';\r\n\r\n        return legendHtml;\r\n    }\r\n\r\n    /**\r\n     * @param {Array} itemIds the items to process\r\n     * @param {LayerGroup} theGroup new group\r\n     * @param {Array} [layerDivClasses=[]] optional classes to apply to the layer divs\r\n     * @static\r\n     * @returns {string} html string\r\n     */\r\n    _buildLegend(itemIds: string[], theGroup: LayerGroup, layerDivClasses: string[]): string {\r\n\r\n        if (itemIds.length == 0) {\r\n            return '';\r\n        }\r\n\r\n        let theHml = '';\r\n\r\n        let itemId = itemIds[0];\r\n\r\n        if (theGroup.groupLayersLookup[itemId]) {\r\n\r\n            /**\r\n             * @type {LayerBase}\r\n             */\r\n            let lyr = theGroup.groupLayersLookup[itemId];\r\n            theHml += `<li id=\"${lyr.id}-layer-li\" class=\"legend-layer-li ${layerDivClasses.join(' ')}\">` + lyr.getLegendDiv() + '</li>';\r\n\r\n\r\n        } else if (theGroup.groupGroupsLookup[itemId]) {\r\n            /**\r\n             * type {LayerGroup}\r\n             */\r\n            let otherGroup = theGroup.groupGroupsLookup[itemId];\r\n\r\n            theHml += `<li>`;\r\n            theHml += `<div id=\"${otherGroup.groupId}-legend-layer-div\" ` +\r\n                `class=\"legend-layer-group  ${layerDivClasses.join(' ')}\">`;\r\n\r\n            if (otherGroup.addCheck) {\r\n                theHml += `<input type=\"checkbox\" checked id=\"${otherGroup.groupId}-group-chck\">` +\r\n                    `<label for=\"${otherGroup.groupId}-group-chck\" title=\"Click arrow to expand or collapse\">${otherGroup.groupName}</label>`;\r\n            } else {\r\n                theHml += `<label title=\"Click arrow to expand or collapse\">${otherGroup.groupName}</label>`;\r\n            }\r\n\r\n            theHml += `<span title=\"Expand/Collapse\" class=\"layer-group-expander`;\r\n            theHml += `${otherGroup.collapse ? ' legend-layer-group-initial-collapse' : ''}\">`;\r\n            theHml += otherGroup.collapse ? '&#9654;' : '&#9660;';\r\n            theHml += '</span>';\r\n\r\n            //parents.push(groupId);\r\n            theHml += '<ul>' + this._buildLegend(otherGroup.itemIdArray, otherGroup, layerDivClasses) + '</ul>';\r\n            theHml += '</div>';\r\n            theHml += '</li>';\r\n        }\r\n\r\n        return theHml + this._buildLegend(itemIds.slice(1), theGroup, layerDivClasses);\r\n    }\r\n}\r\n\r\n\r\n/**\r\n * a wrapper to make a legend\r\n */\r\nexport class LayerLegend {\r\n\r\n    $divElement: JQuery;\r\n    _legendItems: Array<iLegendItem|LayerBase>;\r\n    layerGroup: any;\r\n    legendId: string;\r\n\r\n    /**``\r\n     *\r\n     * @param {Array} legendItems array of layers or objects with {groupName:  {string}, collapse: {boolean}, addCheck: {boolean}, items: {Array}}\r\n     * @param {string} divId the div where the legend should be added\r\n     * @param {object} options for legend\r\n     * @param {Array} [options.layerDivClasses=[]] optional array of classes to be applied to the layer legend divs for custom styling\r\n     * @param {string} [options.legendTitle=Legend] the legend title\r\n     * @param {boolean} [options.scaleDependent=true] if legend display is scale dependent\r\n     */\r\n    constructor(legendItems: Array<iLegendItem|LayerBase>, divId: string, options: iLegendOptions = {}) {\r\n        for (let i of legendItems) {\r\n            if (typeof i == 'undefined') {\r\n                throw 'undefined item passed in array to legend constructor';\r\n            }\r\n        }\r\n\r\n        options.legendTitle = typeof options.legendTitle == 'string' ? options.legendTitle : 'Legend';\r\n        options.scaleDependent = typeof options.scaleDependent == 'boolean' ? options.scaleDependent : true;\r\n        options.layerDivClasses = options.layerDivClasses || [];\r\n\r\n        // if legend display is scale dependent, make sure the mapMove object is initialized first\r\n        if (options.scaleDependent) {\r\n            mapMove.checkInit();\r\n        }\r\n\r\n        this.$divElement = $('#' + divId);\r\n\r\n        this._legendItems = legendItems;\r\n\r\n        this.layerGroup = new LayerGroup();\r\n\r\n        this._buildTree(legendItems);\r\n\r\n        this.legendId = makeGuid();\r\n\r\n        this.$divElement.append(this.layerGroup.getLegendHtml(this.legendId, options));\r\n\r\n        for (let l of this.layerGroup.allLayerArray){\r\n            l.applyCollapse();\r\n        }\r\n\r\n        let _this = this;\r\n        //// if legend display is scale dependent, make sure the mapMove object is initialized first\r\n        if (options.scaleDependent) {\r\n            mapMove.checkInit();\r\n\r\n            mapMove.addCallback(function (ext, zoom, evt) {\r\n\r\n                if (typeof evt == 'undefined' || evt == 'change:resolution') {\r\n                    for (let lyr of this.layerGroup.allLayerArray) {\r\n                        let $lyrLi = $('#' + lyr.id + '-layer-li');\r\n                        if (zoom > lyr.maxZoom || zoom < lyr.minZoom) {\r\n                            $lyrLi.addClass('layer-not-visible');\r\n                        } else {\r\n                            $lyrLi.removeClass('layer-not-visible');\r\n                        }\r\n                    }\r\n                }\r\n            }, this, 100, true, 'legend1');\r\n        }\r\n\r\n        // <editor-fold desc=\"add event listeners\">\r\n\r\n        this.$divElement.find(\".suppress-by-extent\").change(function () {\r\n            let legendLayerLis = $('.legend-layer-li');\r\n            if (this.checked) {\r\n                legendLayerLis.removeClass('layer-force-show');\r\n            } else {\r\n                legendLayerLis.addClass('layer-force-show');\r\n            }\r\n        });\r\n\r\n\r\n        this.$divElement.find('.legend-check').change(function () {\r\n            let lyrId = this.id.replace('-legend-layer-check', '');\r\n            _this.layerGroup.allLayerLookup[lyrId].visible = this.checked;\r\n        });\r\n\r\n        this.$divElement.find('.legend-layer-group > input[type=checkbox]').change(function () {\r\n            $(this).siblings('ul').find('input[type=checkbox]').prop('checked', this.checked).trigger('change');\r\n        });\r\n\r\n        this.$divElement.find('.layer-group-expander').click(function () {\r\n            let $this = $(this);\r\n            $this.removeClass('legend-layer-group-initial-collapse');\r\n\r\n            $this.siblings('ul').slideToggle();\r\n\r\n            if ($this.hasClass('legend-layer-group-collapsed')){\r\n                $this.removeClass('legend-layer-group-collapsed');\r\n                $this.html('&#9660;');\r\n            } else {\r\n                $this.addClass('legend-layer-group-collapsed');\r\n                $this.html('&#9654;');\r\n            }\r\n        });\r\n\r\n        this.$divElement.find('.legend-layer-group-initial-collapse').trigger('click');\r\n        // </editor-fold>\r\n    }\r\n\r\n\r\n    /**\r\n     * @param {Array} [legendItems=this._layerConfig] the legend items\r\n     * @param {Array} [parents=[]] the ordered list of groups in which this item is a member\r\n     * @private\r\n     */\r\n    _buildTree(legendItems: Array<iLegendItem|LayerBase>, parents?: string[]) {\r\n\r\n        if (legendItems.length == 0) {\r\n            return;\r\n        }\r\n\r\n        let oneItem = legendItems[0];\r\n\r\n        //reset the parent if the item is in the base array\r\n        if ((this._legendItems as Array<any>).indexOf(oneItem) > -1 || typeof parents == 'undefined') {\r\n            parents = [];\r\n        }\r\n\r\n        if (typeof (oneItem as iLegendItem).groupName !== 'undefined') {\r\n            let groupItem = legendItems[0];\r\n            let newGroup = this.layerGroup.addGroup(groupItem, parents);\r\n            parents.push(newGroup.groupId);\r\n            this._buildTree((oneItem as iLegendItem).items, parents);\r\n        } else {\r\n            /**\r\n             * @type {LayerBase}\r\n             */\r\n            let layerItem: LayerBase = legendItems[0] as LayerBase;\r\n\r\n            this.layerGroup.addLegendLayer(layerItem, parents);\r\n        }\r\n\r\n        this._buildTree(legendItems.slice(1), parents);\r\n    }\r\n}\r\n\r\nnm.LayerLegend = LayerLegend;\r\nexport default LayerLegend;\r\n"]}