Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,12 @@ export default function MapContainerFactory(
} as Partial<LayerBaseConfig>);
};

_onRedrawNeeded = (_idx: number) => {
// updateMapUpdater always returns a new state object reference, which triggers re-render
const {mapStateActions, index} = this.props;
mapStateActions.updateMap({}, index);
};

_onLayerFilteredItemsChange = (idx, event) => {
this.props.visStateActions.layerFilteredItemsChange(this.props.visState.layers[idx], event);
};
Expand Down Expand Up @@ -841,7 +847,8 @@ export default function MapContainerFactory(
onLayerHover: this._onLayerHover,
onSetLayerDomain: this._onLayerSetDomain,
onFilteredItemsChange: this._onLayerFilteredItemsChange,
onWMSFeatureInfo: this._onWMSFeatureInfo
onWMSFeatureInfo: this._onWMSFeatureInfo,
onRedrawNeeded: this._onRedrawNeeded
},
deckGlProps
);
Expand Down
13 changes: 11 additions & 2 deletions src/layers/src/icon-layer/icon-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
VisConfigNumber,
VisConfigRange,
Merge,
LayerColumn
LayerColumn,
BindedLayerCallbacks
} from '@kepler.gl/types';

export type IconLayerColumnsConfig = {
Expand Down Expand Up @@ -113,6 +114,8 @@ export default class IconLayer extends Layer {
iconGeometry: IconGeometry;
iconGeometryVersion: number;

onRedrawNeeded: BindedLayerCallbacks['onRedrawNeeded'];

declare visConfigSettings: IconLayerVisConfigSettings;
declare config: IconLayerConfig;

Expand Down Expand Up @@ -246,6 +249,9 @@ export default class IconLayer extends Layer {
this.iconGeometryVersion += 1;

this._layerInfoModal = IconInfoModalFactory(svgIcons);

// Trigger a map redraw so deck.gl picks up the new geometry
this.onRedrawNeeded?.();
}

static findDefaultLayerProps({
Expand Down Expand Up @@ -361,7 +367,10 @@ export default class IconLayer extends Layer {
}

renderLayer(opts) {
const {data, gpuFilter, objectHovered, mapState, interactionConfig} = opts;
const {data, gpuFilter, objectHovered, mapState, interactionConfig, layerCallbacks} = opts;

// Store callback to trigger map redraw when icon geometry loads asynchronously
this.onRedrawNeeded = layerCallbacks?.onRedrawNeeded;

const radiusScale = this.getRadiusScaleByZoom(mapState);

Expand Down
2 changes: 2 additions & 0 deletions src/types/layers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ export type LayerCallbacks = {
coordinate?: [number, number] | null;
}
) => void;
onRedrawNeeded?: (idx: number) => void;
};

export type BindedLayerCallbacks = {
Expand All @@ -436,6 +437,7 @@ export type BindedLayerCallbacks = {
featureInfo: Array<{name: string; value: string}> | string | null,
coordinate?: [number, number]
) => void;
onRedrawNeeded?: () => void;
};

export type VisualChannelAggregation = 'colorAggregation' | 'sizeAggregation';
Expand Down