import { DrawPolygonTool } from './draw/DrawPolygonTool'
|
import { DrawRectangleTool } from './draw/DrawRectangleTool'
|
import { DrawEllipseTool } from './draw/DrawEllipseTool'
|
import { DrawBufferCircleTool } from './draw/DrawBufferCircleTool'
|
|
const DRAW_TOOL_MAP = {
|
polygon: DrawPolygonTool,
|
rectangle: DrawRectangleTool,
|
ellipse: DrawEllipseTool,
|
buffer: DrawBufferCircleTool,
|
}
|
|
export class DrawManager {
|
constructor(viewer) {
|
this.viewer = viewer
|
this.activeTool = null
|
}
|
|
start(type, options = {}) {
|
this.destroy()
|
const Tool = DRAW_TOOL_MAP[type]
|
if (!Tool) return null
|
this.activeTool = new Tool(this.viewer, options)
|
this.activeTool.start()
|
return this.activeTool
|
}
|
|
destroy() {
|
if (this.activeTool) {
|
this.activeTool.destroy()
|
this.activeTool = null
|
}
|
}
|
}
|