drawTool.js
1.8 KB
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
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;
}
}