Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.
[fix] fix for image export with effects (#3105)
Igor Dykhtaa231ebfc1bf9
diff --git a/src/components/src/modals/export-image-modal.tsx b/src/components/src/modals/export-image-modal.tsxindex 9ff5e1fde..f710bc384 100644--- a/src/components/src/modals/export-image-modal.tsx+++ b/src/components/src/modals/export-image-modal.tsx@@ -51,7 +51,6 @@ export interface ExportImageModalProps {}const ExportImageModalFactory = () => {- /** @type {typeof import('./export-image-modal').ExportImageModal} */const ExportImageModal: React.FC<ExportImageModalProps> = ({mapW,mapH,diff --git a/src/components/src/plot-container.tsx b/src/components/src/plot-container.tsxindex 4d519ff04..47acab0c3 100644--- a/src/components/src/plot-container.tsx+++ b/src/components/src/plot-container.tsx@@ -20,7 +20,7 @@ import MapsLayoutFactory from './maps-layout';import {MapViewStateContextProvider} from './map-view-state-context';import {GEOCODER_LAYER_ID, ExportImage} from '@kepler.gl/constants';-import {SplitMap} from '@kepler.gl/types';+import {Effect, SplitMap} from '@kepler.gl/types';import {ActionHandler,addNotification,@@ -84,15 +84,27 @@ interface PlotContainerProps {enableErrorNotification?: boolean;}+interface PlotContainerState {+ plotEffects: Effect[];+}+export default function PlotContainerFactory(MapContainer: ReturnType<typeof MapContainerFactory>,MapsLayout: ReturnType<typeof MapsLayoutFactory>): React.ComponentType<PlotContainerProps> {- class PlotContainer extends Component<PlotContainerProps> {+ class PlotContainer extends Component<PlotContainerProps, PlotContainerState> {constructor(props) {super(props);this._onMapRender = debounce(this._onMapRender, 500);this._retrieveNewScreenshot = debounce(this._retrieveNewScreenshot, 500);++ this.state = {+ plotEffects: this.getEffectsForPlot()+ };+ }++ private getEffectsForPlot() {+ return this.props.mapFields.visState.effects.map(effect => effect.clone());}componentDidMount() {@@ -226,6 +238,11 @@ export default function PlotContainerFactory(preserveDrawingBuffer: true,useDevicePixels: false}+ },+ visState: {+ ...mapFields.visState,+ // Make sure to use effects not associated with a different WebGL context+ effects: this.state.plotEffects}};diff --git a/src/effects/src/effect.ts b/src/effects/src/effect.tsindex 3958b92e1..74b9e7c18 100644--- a/src/effects/src/effect.ts+++ b/src/effects/src/effect.ts@@ -50,6 +50,11 @@ export class Effect implements EffectInterface {// implemented in subclasses}+ clone(): Effect {+ const props = this.getDefaultProps(this);+ return new (this.constructor as new (props: EffectPropsPartial) => this)(props);+ }+getDefaultProps(props: EffectPropsPartial = {}): EffectProps {return {id: props.id || `e_${generateHashId(6)}`,diff --git a/src/types/effects.d.ts b/src/types/effects.d.tsindex 93b36b126..eece243c7 100644--- a/src/types/effects.d.ts+++ b/src/types/effects.d.ts@@ -46,4 +46,5 @@ export interface Effect {setProps(props: Partial<EffectProps>): void;isValidToSave(): boolean;getParameterDescriptions(): EffectParameterDescription[];+ clone(): Effect;}