drawTool.js 1.8 KB
import { loadModules } from "esri-loader";
import mapManage from './towMapObjects';
export default class DrawTool {
    static getInstance() {
        mapManage.drawTool || (mapManage.drawTool = new this());
    }
    constructor() {
        this.view = mapManage.mapView;
        this.map = mapManage.mapView.map;
        this.active = !1;
        this.polygon = null;
        this.guids = [];
        loadModules(["esri/symbols/PictureMarkerSymbol", "esri/layers/GraphicsLayer", "esri/views/draw/Draw"]).then(([w, z, d]) => {
            this.options1 || (this.options1 = {}, this.options1.pm = new w({
                url: "", width: "", height: "",  xoffset: 0, yoffset: 0
            }));
            this.map.add(this.graphicsLayer = new z({ id: "drawtool" }));
            this.draw = new Draw({ view: this.view });
        });
    }
    activate(c, b) {
        this.active = !0;
        this.drawType = c.toUpperCase();
        this.callback = b;
        this.guids = [];
        this.downCount = 0;
        this.map.reorder(this.graphicsLayer, this.map.allLayers.length - 1);
        switch (this.drawType) {

            case "POINT1":
            loadModules(["esri/Graphic"]).then(([h, f]) => {
                this.downCount = 0;
                this.view.container.addEventListener('mousedown', b => {
                    var a = new h(b.offsetX, b.offsetY), a = this.view.toMap(a);
                    console.log(a);
                    // this.graphic = new f(a, this.options1.pm, null);
                    // this.graphicsLayer.add(this.graphic);
                    // console.log('OKOKOK');
                    // b.stopPropagation()
                });
            });
            
            break;
        }
    }
    deactivate() {
        this.active = !1;
        this.drawType = "";
        this.downCount = 0;
    }
}