forked from visgl/react-map-gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobe-control.ts
More file actions
26 lines (21 loc) · 759 Bytes
/
globe-control.ts
File metadata and controls
26 lines (21 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import * as React from 'react';
import {useEffect, memo} from 'react';
import {applyReactStyle} from '../utils/apply-react-style';
import {useControl} from './use-control';
import {ControlPosition} from '../types/lib';
export type GlobeControlProps = {
/** Placement of the control relative to the map. */
position?: ControlPosition;
/** CSS style override, applied to the control's container */
style?: React.CSSProperties;
};
function _GlobeControl(props: GlobeControlProps) {
const ctrl = useControl(({mapLib}) => new mapLib.GlobeControl(props), {
position: props.position
});
useEffect(() => {
applyReactStyle(ctrl._container, props.style);
}, [props.style]);
return null;
}
export const GlobeControl = memo(_GlobeControl);