Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

[Enhancement] call layer methods to validate visconfig when switching dataset (#2532)

Igor Dykhta400120f35055
diff --git a/src/reducers/src/vis-state-merger.ts b/src/reducers/src/vis-state-merger.ts
index ced609ba1..2bebe6272 100644
--- a/src/reducers/src/vis-state-merger.ts
+++ b/src/reducers/src/vis-state-merger.ts
@@ -780,11 +780,12 @@ export function validateLayersByDatasets(
*/
// eslint-disable-next-line complexity
export function validateLayerWithData(
- {fields, id: dataId}: KeplerTable,
+ dataset: KeplerTable,
savedLayer: ParsedLayer,
layerClasses: VisState['layerClasses'],
options: ValidateLayerOption = {}
): Layer | null {
+ const {fields, id: dataId} = dataset;
const {type} = savedLayer;
const {throwOnError} = options;
// layer doesnt have a valid type
@@ -832,7 +833,7 @@ export function validateLayerWithData(
: newLayer.config.textLabel;
// copy visConfig over to emptyLayer to make sure it has all the props
- const visConfig = newLayer.copyLayerConfig(
+ const copiedVisConfig = newLayer.copyLayerConfig(
newLayer.config.visConfig,
savedLayer.config.visConfig || {},
{
@@ -840,6 +841,11 @@ export function validateLayerWithData(
}
);
+ // call layer methods to validate visConfig when switching dataset
+ const visConfig = newLayer.validateVisConfig
+ ? newLayer.validateVisConfig(dataset, copiedVisConfig)
+ : copiedVisConfig;
+
newLayer.updateLayerConfig({
visConfig,
textLabel