Skip to content

Commit

Permalink
[fix] Remove split map controls from legend in exported image (#2234)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorDykhta committed Jun 9, 2023
1 parent bc1cfc5 commit 9712615
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
13 changes: 11 additions & 2 deletions src/components/src/map/map-control-panel.tsx
Expand Up @@ -19,7 +19,7 @@
// THE SOFTWARE.

import React, {useCallback} from 'react';
import styled from 'styled-components';
import styled, {StyledComponent} from 'styled-components';
import {FormattedMessage} from '@kepler.gl/localization';
import {CenterFlexbox, IconRoundSmall} from '../common/styled-components';
import {Close, Pin} from '../common/icons';
Expand Down Expand Up @@ -66,7 +66,16 @@ const StyledMapControlPanelHeader = styled.div.attrs({
}
`;

const StyledMapControlPanelHeaderSplitViewportsTools = styled(StyledMapControlPanelHeader)`
const StyledMapControlPanelHeaderSplitViewportsTools: StyledComponent<
'div',
any,
{
className: 'map-control__panel-split-viewport-tools';
},
'className'
> = styled(StyledMapControlPanelHeader).attrs({
className: 'map-control__panel-split-viewport-tools'
})`
display: flex;
flex-direction: column;
justify-content: space-between;
Expand Down
11 changes: 9 additions & 2 deletions src/components/src/plot-container.tsx
Expand Up @@ -44,17 +44,24 @@ import {
} from '@kepler.gl/actions';
import {mapFieldsSelector} from './kepler-gl';

const CLASS_FILTER = ['mapboxgl-control-container', 'attrition-link', 'attrition-logo'];
const CLASS_FILTER = [
'mapboxgl-control-container',
'attrition-link',
'attrition-logo',
'map-control__panel-split-viewport-tools'
];
const DOM_FILTER_FUNC = node => !CLASS_FILTER.includes(node.className);
const OUT_OF_SCREEN_POSITION = -9999;

PlotContainerFactory.deps = [MapContainerFactory, MapsLayoutFactory];

// Remove mapbox logo in exported map, because it contains non-ascii characters
// Remove split viewport UI controls from exported images when the legend is shown
const StyledPlotContainer = styled.div`
.mapboxgl-ctrl-bottom-left,
.mapboxgl-ctrl-bottom-right,
.mapbox-attribution-container {
.mapbox-attribution-container,
.map-control__panel-split-viewport-tools {
display: none;
}
Expand Down

0 comments on commit 9712615

Please sign in to comment.