@geogirafe/lib-geoportal
Version:
GeoGirafe is a flexible application to build online geoportals.
40 lines (39 loc) • 1.65 kB
JavaScript
import Layer from './layer.js';
/*
* 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
*/
class LayerLocalFile extends Layer {
_features;
lastModifiedDate;
legend = true;
isLegendExpanded;
wasLegendExpanded;
extent;
file;
locale;
constructor(id, order, file, features, extent, locale, options) {
super(id, file.name, order, { isDefaultChecked: options?.isDefaultChecked ?? true });
this._features = features;
this.extent = extent;
this.file = file;
this.locale = locale;
this.lastModifiedDate = new Date(file.lastModified).toLocaleDateString(locale);
this.isLegendExpanded = true;
this.wasLegendExpanded = false;
}
clone() {
const clonedObject = new LayerLocalFile(this.id, this.order, this.file, this._features, this.extent, this.locale, {
isDefaultChecked: this.isDefaultChecked
});
clonedObject.activeState = this.activeState;
clonedObject.opacity = this.opacity;
clonedObject.isLegendExpanded = this.isLegendExpanded;
clonedObject.wasLegendExpanded = this.wasLegendExpanded;
return clonedObject;
}
}
export default LayerLocalFile;