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] layer popover mapIndex #2535

Merged
merged 2 commits into from
Mar 7, 2024
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
12 changes: 8 additions & 4 deletions src/actions/src/vis-state-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1006,21 +1006,25 @@ export function toggleFilterFeature(
}

export type OnLayerHoverUpdaterAction = {
info: (PickInfo<any> & {mapIndex?: number}) | null;
info: PickInfo<any> | null;
mapIndex?: number;
};
/**
* Trigger layer hover event with hovered object
* @memberof visStateActions
* @param info - Object hovered, returned by deck.gl. Includes an optional `mapIndex` property for limiting the display of the `<MapPopover>` to the `<MapContainer>` the user is interacting with.
* @param info - Object hovered, returned by deck.gl.
* @param mapIndex - Optional property for limiting the display of the `<MapPopover>` to the `<MapContainer>` the user is interacting with.
* @returns action
* @public
*/
export function onLayerHover(
info: (PickInfo<any> & {mapIndex?: number}) | null
info: PickInfo<any> | null,
mapIndex?: number
): Merge<OnLayerHoverUpdaterAction, {type: typeof ActionTypes.LAYER_HOVER}> {
return {
type: ActionTypes.LAYER_HOVER,
info
info,
mapIndex
};
}

Expand Down
12 changes: 3 additions & 9 deletions src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ export default function MapContainerFactory(
this.props.visStateActions.onLayerClick(null);
};

_onLayerHover = (idx: number, info: PickInfo<any> | null) => {
this.props.visStateActions.onLayerHover(info);
_onLayerHover = (_idx: number, info: PickInfo<any> | null) => {
this.props.visStateActions.onLayerHover(info, this.props.index);
};

_onLayerSetDomain = (idx: number, colorDomain: VisualChannelDomain) => {
Expand Down Expand Up @@ -919,13 +919,7 @@ export default function MapContainerFactory(
};

_onLayerHoverDebounced = debounce((data, index, event) => {
// add `mapIndex` property which will end up in the the `hoverInfo` object of `visState`
// this is for limiting the display of the `<MapPopover>` to the `<MapContainer>` the user is interacting with
// TODO this should be part of onLayerHover arguments, investigate
// @ts-ignore (does not fail with local yarn-test)
data.mapIndex = index;

this.props.visStateActions.onLayerHover(data);
this.props.visStateActions.onLayerHover(data, index);
}, DEBOUNCE_MOUSE_MOVE_PROPAGATE);

_onMouseMoveDebounced = debounce((event, viewport) => {
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/src/vis-state-updaters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,8 @@ export const layerHoverUpdater = (
...state,
hoverInfo: {
// deck.gl info is mutable
...action.info
...action.info,
...(Number.isFinite(action.mapIndex) ? {mapIndex: action.mapIndex} : {})
}
});

Expand Down
17 changes: 13 additions & 4 deletions website/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ const {resolve, join} = require('path');
const webpack = require('webpack');

const KeplerPackage = require('../package');
const {WEBPACK_ENV_VARIABLES, ENV_VARIABLES_WITH_INSTRUCTIONS, RESOLVE_ALIASES} = require('../webpack/shared-webpack-configuration');
const {
WEBPACK_ENV_VARIABLES,
ENV_VARIABLES_WITH_INSTRUCTIONS,
RESOLVE_ALIASES
} = require('../webpack/shared-webpack-configuration');

const LIB_DIR = resolve(__dirname, '..');
const SRC_DIR = resolve(LIB_DIR, './src');
Expand Down Expand Up @@ -69,6 +73,13 @@ const COMMON_CONFIG = {
test: /\.mjs$/,
include: /node_modules\/apache-arrow/,
type: 'javascript/auto'
},
// for compiling @probe.gl, website build started to fail (March, 2024)
{
test: /\.(js)$/,
loader: 'babel-loader',
options: BABEL_CONFIG,
include: /node_modules\/@probe.gl/
}
]
},
Expand Down Expand Up @@ -135,9 +146,7 @@ function logInstruction(msg) {
function validateEnvVariable(variable, instruction) {
if (!process.env[variable]) {
logError(`Error! ${variable} is not defined`);
logInstruction(
`Make sure to run "export ${variable}=<token>" before deploy the website`
);
logInstruction(`Make sure to run "export ${variable}=<token>" before deploy the website`);
logInstruction(instruction);
throw new Error(`Missing ${variable}`);
}
Expand Down
Loading