Skip to content

Commit

Permalink
Update: only create one layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Jul 24, 2024
1 parent 83b16e2 commit 9ef3cc3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/reducers/src/vis-state-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2368,11 +2368,18 @@ export function addDefaultLayers(
datasets: Datasets
): {state: VisState; newLayers: Layer[]} {
const empty: Layer[] = [];
const defaultLayers = Object.values(datasets).reduce((accu: Layer[], dataset) => {
let defaultLayers = Object.values(datasets).reduce((accu: Layer[], dataset) => {
const foundLayers = findDefaultLayer(dataset, state.layerClasses);
return foundLayers && foundLayers.length ? accu.concat(foundLayers) : accu;
}, empty);

// For GeoDa.AI only: check if there is geojson layer in defaultLayers
let newLayer = defaultLayers.find(l => l.type === 'geojson');
if (!newLayer) newLayer = defaultLayers.find(l => l.type === 'point');
if (!newLayer) newLayer = defaultLayers.find(l => l.type === 'line');
// replace defaultLayers with [newLayers]
if (newLayer) defaultLayers = [newLayer];

return {
state: {
...state,
Expand Down

0 comments on commit 9ef3cc3

Please sign in to comment.