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 30 31 32 33 34 35 36 37 38 39 40 41 42 | 1x 1x 1x 1x | /// <reference types="@uiw/react-baidu-map-types" /> import React, { Fragment, useEffect, useImperativeHandle } from 'react'; import { OverlayProps } from '@uiw/react-baidu-map-map'; import { useInfoWindow } from './useInfoWindow'; export * from './useInfoWindow'; export interface InfoWindowProps extends OverlayProps, Omit<BMap.InfoWindowOptions, 'title'>, BMap.InfoWindowEvent { /** * 窗口是否打开 * @default true */ isOpen?: boolean; /** 窗口位置经纬度 */ position: BMap.Point; /** 展示文本内容,支持 HTML 内容字符串 */ content?: string | HTMLElement; /** 信息窗标题文字 */ title?: string | HTMLElement | JSX.Element; /** * 信息窗口最大化时所显示内容,支持HTML内容 */ maxContent?: string; /** * 展示文本内容,类似于 content */ children?: JSX.Element; } export default React.forwardRef<InfoWindowProps & { infoWindow?: BMap.InfoWindow }, InfoWindowProps>((props, ref) => { const { infoWindow, setIsOpen, Portal, PortalTitle } = useInfoWindow(props); useEffect(() => setIsOpen(props.isOpen!), [props.isOpen, setIsOpen]); useImperativeHandle(ref, () => ({ ...props, infoWindow })); return ( <Fragment> <Portal>{props.children}</Portal> <PortalTitle>{props.title as any}</PortalTitle> </Fragment> ); }); |