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

[feat] Add onMouseMove callback #2317

Merged
merged 1 commit into from
Sep 18, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/src/kepler-gl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export const mapFieldsSelector = (props: KeplerGLProps, index: number = 0) => ({
mapStyle: props.mapStyle,
onDeckInitialized: props.onDeckInitialized,
onViewStateChange: props.onViewStateChange,
onMouseMove: props.onMouseMove,
deckGlProps: props.deckGlProps,
uiStateActions: props.uiStateActions,
visStateActions: props.visStateActions,
Expand Down Expand Up @@ -335,6 +336,7 @@ type KeplerGLBasicProps = {
deckGlProps?: object;
onLoadCloudMapSuccess?: OnSuccessCallBack;
onLoadCloudMapError?: OnErrorCallBack;
onMouseMove?: (event: React.MouseEvent & {lngLat?: [number, number]}) => void;
onExportToCloudSuccess?: OnSuccessCallBack;
onExportToCloudError?: OnErrorCallBack;
readOnly?: boolean;
Expand Down
12 changes: 9 additions & 3 deletions src/components/src/map-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,8 @@ export interface MapContainerProps {

generateMapboxLayers?: typeof generateMapboxLayers;
generateDeckGLLayers?: typeof computeDeckLayers;

onMouseMove?: (event: React.MouseEvent & {lngLat?: [number, number]}) => void;
}

export default function MapContainerFactory(
Expand Down Expand Up @@ -669,7 +671,8 @@ export default function MapContainerFactory(
index,
mapControls,
theme,
generateDeckGLLayers
generateDeckGLLayers,
onMouseMove
} = this.props;

const {hoverInfo, editor} = visState;
Expand Down Expand Up @@ -754,8 +757,11 @@ export default function MapContainerFactory(
<div
onMouseMove={
primaryMap
? // @ts-expect-error should be deck viewport
event => this.props.visStateActions.onMouseMove(normalizeEvent(event, viewport))
? event => {
onMouseMove?.(event);
// @ts-expect-error should be deck viewport
this.props.visStateActions.onMouseMove(normalizeEvent(event, viewport));
}
: undefined
}
>
Expand Down