Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 27 28 29 | 1x 1x 1x 1x 1x | import { useEffect, useState } from 'react'; import { useMapContext } from '@uiw/react-baidu-map-map'; import { useVisiable } from '@uiw/react-baidu-map-utils'; import { PanoramaControlProps } from './'; export interface UsePanoramaControl extends PanoramaControlProps {} export function usePanoramaControl(props = {} as UsePanoramaControl) { const [panoramaControl, setPanoramaControl] = useState<BMap.PanoramaControl>(); const { map } = useMapContext(); useEffect(() => { if (map && !panoramaControl) { const instance = new BMap.PanoramaControl(); map.addControl(instance); setPanoramaControl(instance); return () => { map.removeControl(instance); }; } // eslint-disable-next-line react-hooks/exhaustive-deps }, [map]); useVisiable(panoramaControl!, props); return { panoramaControl, setPanoramaControl, }; } |