UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

48 lines (47 loc) 1.95 kB
import Layer from './layer'; class LayerCog extends Layer { constructor(id, name, order, source, options) { let opts = options ?? {}; opts = LayerCog.isGMFTreeItem(opts) ? LayerCog.getOptionsFromGMFTreeItem(opts) : opts; super(id, name, order, opts); /** * This class is a used in the state of the application, which will be accessed behind a javascript proxy. * This means that each modification made to its properties must come from outside, * because they have to be made through the proxy, so that the modification can be listen. * Therefore, this class must not contain any method which is updating a value directly * For example, any method doing <this.xxx = value> is forbidden here, because the modification be known from the proxy */ Object.defineProperty(this, "source", { enumerable: true, configurable: true, writable: true, value: void 0 }); this.source = source; } clone() { const options = { isDefaultChecked: this.isDefaultChecked, metadataUrl: this.metadataUrl, disclaimer: this.disclaimer, opacity: this.opacity, protected: this.protected }; const clonedObject = new LayerCog(this.id, this.name, this.order, this.source, options); clonedObject.activeState = this.activeState; return clonedObject; } static isGMFTreeItem(options) { return 'id' in options; } static getOptionsFromGMFTreeItem(options) { return { isDefaultChecked: options.metadata?.isChecked, metadataUrl: options.metadata?.metadataUrl, disclaimer: options.metadata?.disclaimer, opacity: 1, // TODO REG : Set default opacity protected: options.metadata?.protected }; } } export default LayerCog;