-
Notifications
You must be signed in to change notification settings - Fork 31
/
Toolbar.js
54 lines (39 loc) · 1.53 KB
/
Toolbar.js
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
52
53
54
const {defined, DeveloperError} = window.Cesium;
import CutVolumeMeasurer from "./CutVolumeMeasurer.js"
export default class Toolbar {
constructor(cutVolumeMeasurer, options) {
//container must be specified
if (!(cutVolumeMeasurer instanceof CutVolumeMeasurer)) {
throw new DeveloperError('CutVolumeMeasurer is required');
}
if (!(defined(options.container))) {
throw new DeveloperError('Container is required');
}
this._container = document.createElement('div');
this._container.className = 'cesiumMeasureToolbar';
options.container.appendChild(this._container);
const drawOptions = {
measureTerrainVolumeIcon: "./img/measure_terrain_volume.png",
cleaningIcon: "./img/cleaning.png"
};
this.addButton(drawOptions.measureTerrainVolumeIcon, function () {
cutVolumeMeasurer.cleanUp();
cutVolumeMeasurer.startDrawing({});
});
this.addButton(drawOptions.cleaningIcon, function () {
cutVolumeMeasurer.cleanUp();
})
}
addButton(imgUrl, callback) {
const div = document.createElement('div');
div.className = 'cesiumMeasureToolbarButton';
this._container.appendChild(div);
div.onclick = callback;
const span = document.createElement('span');
div.appendChild(span);
const image = document.createElement('img');
image.src = imgUrl;
span.appendChild(image);
return div;
}
}