Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
fix: colors not working in trip layer of TABLE mode (#3347)
Xun Liefb072eb56fa
diff --git a/.gitignore b/.gitignoreindex eee7b750b..1cbfe9f5a 100644--- a/.gitignore+++ b/.gitignore@@ -8,6 +8,10 @@ build/umd/*/**/dist/+__pycache__/+.pytest_cache/+.ipynb_checkpoints/+bindings/python/keplergl/static/typedoc/examples/**/yarn.lockdiff --git a/src/layers/src/geojson-layer/geojson-layer.ts b/src/layers/src/geojson-layer/geojson-layer.tsindex ebae09451..dbb5906f9 100644--- a/src/layers/src/geojson-layer/geojson-layer.ts+++ b/src/layers/src/geojson-layer/geojson-layer.ts@@ -515,10 +515,13 @@ export default class GeoJsonLayer extends Layer {let dataAccessor;if (this.config.columnMode === COLUMN_MODE_GEOJSON) {filterValueAccessor = (dc, d, fieldIndex) => dc.valueAt(d.properties.index, fieldIndex);+ // For GEOJSON mode, properties.index is the row index in the data containerdataAccessor = () => d => ({index: d.properties.index});} else {filterValueAccessor = getTableModeValueAccessor;- dataAccessor = () => d => ({index: d.properties.index});+ // For TABLE mode, properties.index is the feature index (not row index).+ // Use the first row from properties.values to get field values for color/size.+ dataAccessor = () => d => d.properties.values[0];}const indexAccessor = f => f.properties.index;diff --git a/src/layers/src/trip-layer/trip-layer.ts b/src/layers/src/trip-layer/trip-layer.tsindex 560a168ca..2f948814b 100644--- a/src/layers/src/trip-layer/trip-layer.ts+++ b/src/layers/src/trip-layer/trip-layer.ts@@ -362,15 +362,20 @@ export default class TripLayer extends Layer {const {data} = this.updateData(datasets, oldLayerData);let valueAccessor;+ let dataAccessor;if (this.config.columnMode === COLUMN_MODE_GEOJSON) {valueAccessor = (dc: DataContainerInterface, f, fieldIndex: number) => {return dc.valueAt(f.properties.index, fieldIndex);};+ // For GEOJSON mode, properties.index is the row index in the data container+ dataAccessor = () => d => ({index: d.properties.index});} else {valueAccessor = getTableModeValueAccessor;+ // For TABLE mode, properties.index is the feature index (not row index).+ // Use the first row from properties.values to get field values for color/size.+ dataAccessor = () => d => d.properties.values[0];}const indexAccessor = f => f.properties.index;- const dataAccessor = () => d => ({index: d.properties.index});const accessors = this.getAttributeAccessors({dataAccessor, dataContainer});const getFilterValue = gpuFilter.filterValueAccessor(dataContainer)(indexAccessor,