All files / marker/src index.tsx

66.66% Statements 4/6
0% Branches 0/2
33.33% Functions 1/3
100% Lines 4/4

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                                                                                                  1x   1x 1x 1x    
/// <reference types="@uiw/react-baidu-map-types" />
import React, { useEffect, useImperativeHandle } from 'react';
import { OverlayProps } from '@uiw/react-baidu-map-map';
import { useMarker } from './useMarker';
 
export * from './useMarker';
export interface MarkerProps extends OverlayProps, BMap.MarkerEvents, BMap.MarkerOptions {
  /**
   * **`必填`** 设置标注的地理坐标。
   */
  position: BMap.Point;
  /**
   * 此常量表示标注的动画效果。
   */
  animation?: BMap.Animation;
  /**
   * 标点类型
   */
  type?:
    | 'location'
    | 'end'
    | 'start'
    | 'simple_red'
    | 'simple_blue'
    | 'loc_blue'
    | 'loc_red'
    | 'dot_red'
    | 'dot_blue'
    | 'red1'
    | 'red2'
    | 'red3'
    | 'red4'
    | 'red5'
    | 'red6'
    | 'red7'
    | 'red8'
    | 'red9'
    | 'blue1'
    | 'blue2'
    | 'blue3'
    | 'blue4'
    | 'blue5'
    | 'blue6'
    | 'blue7'
    | 'blue8'
    | 'blue9';
}
 
export default React.forwardRef<MarkerProps & { marker?: BMap.Marker }, MarkerProps>((props, ref) => {
  const { marker, setType } = useMarker(props);
  // eslint-disable-next-line react-hooks/exhaustive-deps
  useEffect(() => props.type && setType(props.type), [props.type]);
  useImperativeHandle(ref, () => ({ ...props, marker }));
  return null;
});