Skip to content

LineCollection 线集合类

判定

isLineCollection()

typescript
const isLineCollection: (tar: any) => tar is LineCollection

属性

redonlay id: string 唯一标识

size: number 子元素数量

show: boolean 是否显示

label: HtmlLabel

方法

add 添加线

typescript
add(options: LineCollectionOptions['addOptions']): Polyline

type LineCollectionOptions = {
  addOptions: {
    /** 唯一标识 */
    id?: string;
    /** 显示消失 */
    show?: boolean;
    /** 线宽 */
    width?: number;
    /** 坐标串 */
    positions: Array<Point3d> | Array<[number, number, number?]>;
    /** material为空时有效 线的类型,实线,虚线,带箭头, 发光, 描边的线 */
    type?: 'dotted' | 'line' | 'arrow' | 'glow' | 'outline';
    /** 颜色 */
    color?: MapColor;
    /** 近距离 */
    near?: number;
    /** 远距离 */
    far?: number;
    labelOffset?: [number, number];
    property?: Record<string | symbol, any>;
    /** 虚线配置 */
    dotted?: {
      /** 线段长度 */
      dashLength?: number;
      /** 线段间隔 */
      dashPattern?: number;
    };
    /** 描边配置 */
    outline?: {
      /** 描边宽度 */
      outlineWidth?: number;
      /** 描边颜色 */
      outlineColor?: MapColor;
    };
  };
};

get 获取

  • id 子元素id
typescript
get(id: string): Polyline | undefined

setLine 设置改变子元素样式

typescript
setLine(id: string, options: Partial<Omit<LineCollectionOptions['addOptions'], 'id' | 'near' | 'far' | 'property'>> & { material?: Material }): Polyline | undefined

getProperty 获取属性

  • id 子元素id
typescript
getProperty(id: string): Record<string | symbol, any> | undefined

remove 移除点

  • id 子元素id
  • isRender 移除后是否进行渲染 默认true
typescript
remove(id: string, isRender: boolean): boolean

removeAll 移除所有点

  • isRender 移除后是否进行渲染 默认true
typescript
removeAll(isRender: boolean): void

on 事件注册

  • 两个函数重载
typescript
 on(type: 'mouseMove', listener: (tar: [LineCollection, Polyline | undefined], mark: 'in' | 'out', Even: MouseMoveEvent) => void): LineCollection;
 on(type: PickType, listener: (tar: [LineCollection, Polyline | undefined], mark: 'in' | 'out', Even: PickEvent) => void): LineCollection;

off 事件移除

typescript
off(type: PickType | 'mouseMove'): LineCollection

focus 聚焦

  • id 子元素id
  • duration 过渡时间(秒)
typescript
focus(id: string, duration): void

destroy 销毁

typescript
destroy(): boolean