Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix] Improved split+unsynced mode for better handling #2176

Merged
merged 2 commits into from
Mar 30, 2023
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
1 change: 1 addition & 0 deletions src/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export type {DatasetTagProps} from './side-panel/common/dataset-tag';
export type {CustomPanelsProps} from './side-panel/custom-panel';
export type {LayerTypeListItemType} from './side-panel/layer-panel/layer-type-list-item';
export type {LayerGroupColorPickerProps} from './side-panel/map-style-panel/map-layer-group-color-picker';
export type {MapLegendPanelProps, MapLegendPanelFactoryDeps} from './map/map-legend-panel';

export {
Icons,
Expand Down
6 changes: 4 additions & 2 deletions src/components/src/map/map-control-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ export type MapControlPanelProps = {
logoComponent?: Element;
mapState?: MapState;
onToggleSplitMapViewport?: ActionHandler<typeof toggleSplitMapViewport>;
isViewportUnsyncAllowed?: boolean;
};

function MapControlPanelFactory() {
Expand All @@ -122,7 +123,8 @@ function MapControlPanelFactory() {
isExport,
logoComponent,
mapState,
onToggleSplitMapViewport
onToggleSplitMapViewport,
isViewportUnsyncAllowed
}) => {
const {isViewportSynced, isZoomLocked} = mapState || {};
const onUnlockViewportChange = useCallback(() => {
Expand All @@ -141,7 +143,7 @@ function MapControlPanelFactory() {
marginBottom: '8px !important'
}}
>
{mapState?.isSplit ? (
{mapState?.isSplit && isViewportUnsyncAllowed ? (
<StyledMapControlPanelHeaderSplitViewportsTools>
<StyledSBCenterFlexbox style={{paddingBottom: '6px'}}>
<FormattedMessage id="Unlock Viewport" />
Expand Down
10 changes: 9 additions & 1 deletion src/components/src/map/map-legend-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ import {ActionHandler, toggleSplitMapViewport} from '@kepler.gl/actions';

MapLegendPanelFactory.deps = [MapControlTooltipFactory, MapControlPanelFactory, MapLegendFactory];

export type MapLegendPanelFactoryDeps = [
typeof MapControlTooltipFactory,
typeof MapControlPanelFactory,
typeof MapLegendFactory
];
interface PinToBottomProps {
offsetRight?: number;
}
Expand Down Expand Up @@ -71,6 +76,7 @@ export type MapLegendPanelProps = {
mapHeight?: number;
offsetRight?: number;
onToggleSplitMapViewport?: ActionHandler<typeof toggleSplitMapViewport>;
isViewportUnsyncAllowed?: boolean;
};

function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
Expand All @@ -89,7 +95,8 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
mapState,
mapHeight,
offsetRight,
onToggleSplitMapViewport
onToggleSplitMapViewport,
isViewportUnsyncAllowed = true
}) => {
const mapLegend = mapControls?.mapLegend || ({} as MapControl);
const {active: isPinned} = mapLegend || {};
Expand Down Expand Up @@ -136,6 +143,7 @@ function MapLegendPanelFactory(MapControlTooltip, MapControlPanel, MapLegend) {
logoComponent={logoComponent}
mapState={mapState}
onToggleSplitMapViewport={onToggleSplitMapViewport}
isViewportUnsyncAllowed={isViewportUnsyncAllowed}
>
<MapLegend layers={layers} mapHeight={mapHeight} />
</MapControlPanel>
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/src/map-state-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export const toggleSplitMapViewportUpdater = (
state: MapState,
action: MapStateActions.ToggleSplitMapViewportUpdaterAction
) => {
// new map state immediately gets the new payload values for isViewportSynced and isZoomLocked
// new map state immediately gets the new, optional payload values for isViewportSynced and/or isZoomLocked
const newMapState = {
...state,
...(action.payload || {})
Expand Down