@antv/l7-scene 2.21.1 → 2.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/boxSelect.js +99 -115
- package/es/index.js +432 -681
- package/lib/ILayerManager.d.ts +9 -0
- package/lib/IMapController.d.ts +62 -0
- package/lib/IPostProcessingPassPluggable.d.ts +9 -0
- package/lib/boxSelect.d.ts +23 -0
- package/lib/index.d.ts +132 -0
- package/lib/index.js +59 -13
- package/package.json +19 -22
- package/CHANGELOG.md +0 -275
- package/LICENSE.md +0 -21
package/es/boxSelect.js
CHANGED
|
@@ -1,120 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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
|
-
_this.emit('selecting', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
33
|
-
});
|
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "onDragEnd", function (e) {
|
|
35
|
-
_this.endEvent = e;
|
|
36
|
-
_this.box.style.display = 'none';
|
|
37
|
-
_this.emit('selectend', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
38
|
-
});
|
|
39
|
-
_this.scene = scene;
|
|
40
|
-
_this.options = options;
|
|
41
|
-
return _this;
|
|
1
|
+
// src/boxSelect.ts
|
|
2
|
+
import { DOM, getBBoxFromPoints } from "@antv/l7-utils";
|
|
3
|
+
import { EventEmitter } from "eventemitter3";
|
|
4
|
+
var BoxSelectEventList = ["selectstart", "selecting", "selectend"];
|
|
5
|
+
var BoxSelect = class extends EventEmitter {
|
|
6
|
+
constructor(scene, options = {}) {
|
|
7
|
+
super();
|
|
8
|
+
this.isEnable = false;
|
|
9
|
+
this.onDragStart = (e) => {
|
|
10
|
+
this.box.style.display = "block";
|
|
11
|
+
this.startEvent = this.endEvent = e;
|
|
12
|
+
this.syncBoxBound();
|
|
13
|
+
this.emit(
|
|
14
|
+
"selectstart",
|
|
15
|
+
this.getLngLatBox(),
|
|
16
|
+
this.startEvent,
|
|
17
|
+
this.endEvent
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
this.onDragging = (e) => {
|
|
21
|
+
this.endEvent = e;
|
|
22
|
+
this.syncBoxBound();
|
|
23
|
+
this.emit("selecting", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
24
|
+
};
|
|
25
|
+
this.onDragEnd = (e) => {
|
|
26
|
+
this.endEvent = e;
|
|
27
|
+
this.box.style.display = "none";
|
|
28
|
+
this.emit("selectend", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
29
|
+
};
|
|
30
|
+
this.scene = scene;
|
|
31
|
+
this.options = options;
|
|
42
32
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
key: "enable",
|
|
50
|
-
value: function enable() {
|
|
51
|
-
if (this.isEnable) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
var className = this.options.className;
|
|
55
|
-
this.scene.setMapStatus({
|
|
56
|
-
dragEnable: false
|
|
57
|
-
});
|
|
58
|
-
this.container.style.cursor = 'crosshair';
|
|
59
|
-
if (!this.box) {
|
|
60
|
-
var box = DOM.create('div', undefined, this.container);
|
|
61
|
-
box.classList.add('l7-select-box');
|
|
62
|
-
if (className) {
|
|
63
|
-
box.classList.add(className);
|
|
64
|
-
}
|
|
65
|
-
box.style.display = 'none';
|
|
66
|
-
this.box = box;
|
|
67
|
-
}
|
|
68
|
-
this.scene.on('dragstart', this.onDragStart);
|
|
69
|
-
this.scene.on('dragging', this.onDragging);
|
|
70
|
-
this.scene.on('dragend', this.onDragEnd);
|
|
71
|
-
this.isEnable = true;
|
|
33
|
+
get container() {
|
|
34
|
+
return this.scene.getMapService().getMarkerContainer();
|
|
35
|
+
}
|
|
36
|
+
enable() {
|
|
37
|
+
if (this.isEnable) {
|
|
38
|
+
return;
|
|
72
39
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
40
|
+
const { className } = this.options;
|
|
41
|
+
this.scene.setMapStatus({
|
|
42
|
+
dragEnable: false
|
|
43
|
+
});
|
|
44
|
+
this.container.style.cursor = "crosshair";
|
|
45
|
+
if (!this.box) {
|
|
46
|
+
const box = DOM.create(
|
|
47
|
+
"div",
|
|
48
|
+
void 0,
|
|
49
|
+
this.container
|
|
50
|
+
);
|
|
51
|
+
box.classList.add("l7-select-box");
|
|
52
|
+
if (className) {
|
|
53
|
+
box.classList.add(className);
|
|
78
54
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
this.container.style.cursor = 'auto';
|
|
83
|
-
this.scene.off('dragstart', this.onDragStart);
|
|
84
|
-
this.scene.off('dragging', this.onDragging);
|
|
85
|
-
this.scene.off('dragend', this.onDragEnd);
|
|
86
|
-
this.isEnable = false;
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "syncBoxBound",
|
|
90
|
-
value: function syncBoxBound() {
|
|
91
|
-
var _this$startEvent = this.startEvent,
|
|
92
|
-
x1 = _this$startEvent.x,
|
|
93
|
-
y1 = _this$startEvent.y;
|
|
94
|
-
var _this$endEvent = this.endEvent,
|
|
95
|
-
x2 = _this$endEvent.x,
|
|
96
|
-
y2 = _this$endEvent.y;
|
|
97
|
-
var left = Math.min(x1, x2);
|
|
98
|
-
var top = Math.min(y1, y2);
|
|
99
|
-
var width = Math.abs(x1 - x2);
|
|
100
|
-
var height = Math.abs(y1 - y2);
|
|
101
|
-
this.box.style.top = "".concat(top, "px");
|
|
102
|
-
this.box.style.left = "".concat(left, "px");
|
|
103
|
-
this.box.style.width = "".concat(width, "px");
|
|
104
|
-
this.box.style.height = "".concat(height, "px");
|
|
55
|
+
box.style.display = "none";
|
|
56
|
+
this.box = box;
|
|
105
57
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
lat2 = _this$endEvent$lngLat.lat;
|
|
115
|
-
return getBBoxFromPoints([[lng1, lat1], [lng2, lat2]]);
|
|
58
|
+
this.scene.on("dragstart", this.onDragStart);
|
|
59
|
+
this.scene.on("dragging", this.onDragging);
|
|
60
|
+
this.scene.on("dragend", this.onDragEnd);
|
|
61
|
+
this.isEnable = true;
|
|
62
|
+
}
|
|
63
|
+
disable() {
|
|
64
|
+
if (!this.isEnable) {
|
|
65
|
+
return;
|
|
116
66
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
67
|
+
this.scene.setMapStatus({
|
|
68
|
+
dragEnable: true
|
|
69
|
+
});
|
|
70
|
+
this.container.style.cursor = "auto";
|
|
71
|
+
this.scene.off("dragstart", this.onDragStart);
|
|
72
|
+
this.scene.off("dragging", this.onDragging);
|
|
73
|
+
this.scene.off("dragend", this.onDragEnd);
|
|
74
|
+
this.isEnable = false;
|
|
75
|
+
}
|
|
76
|
+
syncBoxBound() {
|
|
77
|
+
const { x: x1, y: y1 } = this.startEvent;
|
|
78
|
+
const { x: x2, y: y2 } = this.endEvent;
|
|
79
|
+
const left = Math.min(x1, x2);
|
|
80
|
+
const top = Math.min(y1, y2);
|
|
81
|
+
const width = Math.abs(x1 - x2);
|
|
82
|
+
const height = Math.abs(y1 - y2);
|
|
83
|
+
this.box.style.top = `${top}px`;
|
|
84
|
+
this.box.style.left = `${left}px`;
|
|
85
|
+
this.box.style.width = `${width}px`;
|
|
86
|
+
this.box.style.height = `${height}px`;
|
|
87
|
+
}
|
|
88
|
+
getLngLatBox() {
|
|
89
|
+
const {
|
|
90
|
+
lngLat: { lng: lng1, lat: lat1 }
|
|
91
|
+
} = this.startEvent;
|
|
92
|
+
const {
|
|
93
|
+
lngLat: { lng: lng2, lat: lat2 }
|
|
94
|
+
} = this.endEvent;
|
|
95
|
+
return getBBoxFromPoints([
|
|
96
|
+
[lng1, lat1],
|
|
97
|
+
[lng2, lat2]
|
|
98
|
+
]);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export {
|
|
102
|
+
BoxSelectEventList,
|
|
103
|
+
BoxSelect as default
|
|
104
|
+
};
|