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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import { useState, useMemo } from 'react'; import { useMapContext } from '@uiw/react-baidu-map-map'; import { useEnableProperties, useProperties, useVisiable, useEventProperties } from '@uiw/react-baidu-map-utils'; import { CircleProps } from './'; export interface UseCircle extends CircleProps {} export function useCircle(props = {} as UseCircle) { const { center, radius, strokeColor, fillColor, strokeWeight, strokeOpacity, fillOpacity, strokeStyle, enableMassClear, enableEditing, enableClicking, } = props; const { map } = useMapContext(); const [circle, setCircle] = useState<BMap.Circle>(); useMemo(() => { Iif (map && !circle) { let point = center; if (center && center.lng && center.lat) { point = new BMap.Point(center.lng, center.lat); } const opts = { strokeColor, fillColor, strokeWeight, strokeOpacity, fillOpacity, strokeStyle, enableMassClear, enableEditing, enableClicking, }; const instance = new BMap.Circle(point, radius, opts); map.addOverlay(instance); setCircle(instance); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [map, circle]); useVisiable(circle!, props); useEventProperties<BMap.Circle, UseCircle>(circle!, props, [ 'Click', 'DblClick', 'MouseDown', 'MouseUp', 'MouseOut', 'MouseOver', 'Remove', 'LineUpdate', ]); useEnableProperties<BMap.Circle, UseCircle>(circle!, props, ['Editing', 'MassClear']); useProperties<BMap.Circle, UseCircle>(circle!, props, [ 'Center', 'Radius', 'StrokeColor', 'FillColor', 'StrokeOpacity', 'FillOpacity', 'StrokeWeight', 'StrokeStyle', ]); return { circle, setCircle, }; } |