in public/js/components/app.js [81:181]
constructor(props) {
super(props);
this.state = {
selectedTileLayer: null,
selectedFileLayer: null,
selectedLanguage: 'default',
selectedColor: null,
selectedColorOp: null,
selectedPercentage: null,
jsonFeatures: null,
initialSelection: null,
toasts: []
};
this._selectFileLayer = async (fileLayerConfig, skipZoom) => {
try {
this._featuretable?.startLoading();
const featureCollection = await fileLayerConfig.getGeoJson();
featureCollection.features.forEach((feature, index) => {
feature.properties.__id__ = index;
});
this.setState({
selectedFileLayer: fileLayerConfig,
jsonFeatures: featureCollection,
});
this._setFileRoute(fileLayerConfig);
this._map.setOverlayLayer(featureCollection, skipZoom, this.state.selectedColor);
this._featuretable?.stopLoading();
} catch (error) {
this._addToast(
'There was an error',
<p><EuiCode>{error.message}</EuiCode></p>
);
}
};
this._showFeature = (feature) => {
this._map.highlightFeature(feature);
};
this._filterFeatures = (features) => {
this._map.filterFeatures(features);
};
this._getTmsSource = (cfg) => cfg.getVectorStyleSheet();
this._selectLanguage = (lang) => {
this.setState({ selectedLanguage: lang }, () => {
this._updateMap();
});
};
this._selectTmsLayer = async (config) => {
const source = await this._getTmsSource(config);
const { operation, percentage } = TMSService.colorOperationDefaults.find(c => c.style === config.getId());
this.setState({
selectedTileLayer: config,
selectedColorOp: operation,
selectedPercentage: percentage
}, () => {
this._map.setTmsLayer(source, () => {
this._updateMap();
});
});
};
this._changeColor = async (color) => {
this.setState({ selectedColor: color }, async () => {
await this._updateMap();
if (this.state.selectedFileLayer) {
this._selectFileLayer(this.state.selectedFileLayer, true);
}
});
};
this._addToast = (title, text) => {
this.setState({
toasts: [{
id: 'error',
color: 'danger',
title,
text
}]
});
};
this._removeToast = () => {
this.setState({
toasts: []
});
};
this._map = null;
this._toc = null;
this._featuretable = null;
}