吉安感知网项目-前端
chenyao
20 hours ago c567cbca3b78a7e06a827acbab56a46657e31aa1
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
import { EditPolygonTool } from './edit/EditPolygonTool'
import { EditRectangleTool } from './edit/EditRectangleTool'
import { EditEllipseTool } from './edit/EditEllipseTool'
import { EditBufferCircleTool } from './edit/EditBufferCircleTool'
 
const EDIT_TOOL_MAP = {
    polygon: EditPolygonTool,
    rectangle: EditRectangleTool,
    ellipse: EditEllipseTool,
    buffer: EditBufferCircleTool,
}
 
export class EditManager {
    constructor(viewer) {
        this.viewer = viewer
        this.activeTool = null
    }
 
    start(type, data, options = {}) {
        this.destroy()
        const Tool = EDIT_TOOL_MAP[type]
        if (!Tool) return null
        this.activeTool = new Tool(this.viewer, options)
        this.activeTool.start(data)
        return this.activeTool
    }
 
    destroy() {
        if (this.activeTool) {
            this.activeTool.destroy()
            this.activeTool = null
        }
    }
}