@antv/l7-scene 2.9.35 → 2.9.36-alpha.1
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.d.ts +23 -0
- package/es/boxSelect.js +149 -0
- package/es/index.d.ts +5 -1
- package/es/index.js +55 -3
- package/lib/boxSelect.js +126 -0
- package/lib/index.js +45 -3
- package/package.json +11 -9
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EventEmitter } from 'eventemitter3';
|
|
2
|
+
import { Scene } from './index';
|
|
3
|
+
export declare const BoxSelectEventList: string[];
|
|
4
|
+
export declare type BoxSelectOptions = {
|
|
5
|
+
className?: string;
|
|
6
|
+
};
|
|
7
|
+
export default class BoxSelect extends EventEmitter {
|
|
8
|
+
protected scene: Scene;
|
|
9
|
+
protected options: BoxSelectOptions;
|
|
10
|
+
protected isEnable: boolean;
|
|
11
|
+
protected box: HTMLElement;
|
|
12
|
+
protected startEvent: any;
|
|
13
|
+
protected endEvent: any;
|
|
14
|
+
constructor(scene: Scene, options?: BoxSelectOptions);
|
|
15
|
+
get container(): HTMLElement;
|
|
16
|
+
enable(): void;
|
|
17
|
+
disable(): void;
|
|
18
|
+
protected onDragStart: (e: any) => void;
|
|
19
|
+
protected onDragging: (e: any) => void;
|
|
20
|
+
protected onDragEnd: (e: any) => void;
|
|
21
|
+
protected syncBoxBound(): void;
|
|
22
|
+
protected getLngLatBox(): import("@turf/helpers").BBox;
|
|
23
|
+
}
|
package/es/boxSelect.js
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
9
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
+
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
|
|
13
|
+
import { DOM } from '@antv/l7-utils';
|
|
14
|
+
import { EventEmitter } from 'eventemitter3';
|
|
15
|
+
import bbox from '@turf/bbox';
|
|
16
|
+
import { featureCollection, lineString } from '@turf/helpers';
|
|
17
|
+
export var BoxSelectEventList = ['selectstart', 'selecting', 'selectend'];
|
|
18
|
+
|
|
19
|
+
var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
20
|
+
_inherits(BoxSelect, _EventEmitter);
|
|
21
|
+
|
|
22
|
+
var _super = _createSuper(BoxSelect);
|
|
23
|
+
|
|
24
|
+
function BoxSelect(scene) {
|
|
25
|
+
var _this;
|
|
26
|
+
|
|
27
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
28
|
+
|
|
29
|
+
_classCallCheck(this, BoxSelect);
|
|
30
|
+
|
|
31
|
+
_this = _super.call(this);
|
|
32
|
+
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "isEnable", false);
|
|
34
|
+
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (e) {
|
|
36
|
+
_this.box.style.display = 'block';
|
|
37
|
+
_this.startEvent = _this.endEvent = e;
|
|
38
|
+
|
|
39
|
+
_this.syncBoxBound();
|
|
40
|
+
|
|
41
|
+
_this.emit('selectstart', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_defineProperty(_assertThisInitialized(_this), "onDragging", function (e) {
|
|
45
|
+
_this.endEvent = e;
|
|
46
|
+
|
|
47
|
+
_this.syncBoxBound();
|
|
48
|
+
|
|
49
|
+
_this.emit('selecting', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
_defineProperty(_assertThisInitialized(_this), "onDragEnd", function (e) {
|
|
53
|
+
_this.endEvent = e;
|
|
54
|
+
_this.box.style.display = 'none';
|
|
55
|
+
|
|
56
|
+
_this.emit('selectend', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
_this.scene = scene;
|
|
60
|
+
_this.options = options;
|
|
61
|
+
return _this;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
_createClass(BoxSelect, [{
|
|
65
|
+
key: "container",
|
|
66
|
+
get: function get() {
|
|
67
|
+
return this.scene.getMapService().getMarkerContainer();
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
key: "enable",
|
|
71
|
+
value: function enable() {
|
|
72
|
+
if (this.isEnable) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var className = this.options.className;
|
|
77
|
+
this.scene.setMapStatus({
|
|
78
|
+
dragEnable: false
|
|
79
|
+
});
|
|
80
|
+
this.container.style.cursor = 'crosshair';
|
|
81
|
+
|
|
82
|
+
if (!this.box) {
|
|
83
|
+
var box = DOM.create('div', undefined, this.container);
|
|
84
|
+
box.classList.add('l7-select-box');
|
|
85
|
+
|
|
86
|
+
if (className) {
|
|
87
|
+
box.classList.add(className);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
box.style.display = 'none';
|
|
91
|
+
this.box = box;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
this.scene.on('dragstart', this.onDragStart);
|
|
95
|
+
this.scene.on('dragging', this.onDragging);
|
|
96
|
+
this.scene.on('dragend', this.onDragEnd);
|
|
97
|
+
this.isEnable = true;
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "disable",
|
|
101
|
+
value: function disable() {
|
|
102
|
+
if (!this.isEnable) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.scene.setMapStatus({
|
|
107
|
+
dragEnable: true
|
|
108
|
+
});
|
|
109
|
+
this.container.style.cursor = 'auto';
|
|
110
|
+
this.scene.off('dragstart', this.onDragStart);
|
|
111
|
+
this.scene.off('dragging', this.onDragging);
|
|
112
|
+
this.scene.off('dragend', this.onDragEnd);
|
|
113
|
+
this.isEnable = false;
|
|
114
|
+
}
|
|
115
|
+
}, {
|
|
116
|
+
key: "syncBoxBound",
|
|
117
|
+
value: function syncBoxBound() {
|
|
118
|
+
var _this$startEvent = this.startEvent,
|
|
119
|
+
x1 = _this$startEvent.x,
|
|
120
|
+
y1 = _this$startEvent.y;
|
|
121
|
+
var _this$endEvent = this.endEvent,
|
|
122
|
+
x2 = _this$endEvent.x,
|
|
123
|
+
y2 = _this$endEvent.y;
|
|
124
|
+
var left = Math.min(x1, x2);
|
|
125
|
+
var top = Math.min(y1, y2);
|
|
126
|
+
var width = Math.abs(x1 - x2);
|
|
127
|
+
var height = Math.abs(y1 - y2);
|
|
128
|
+
this.box.style.top = "".concat(top, "px");
|
|
129
|
+
this.box.style.left = "".concat(left, "px");
|
|
130
|
+
this.box.style.width = "".concat(width, "px");
|
|
131
|
+
this.box.style.height = "".concat(height, "px");
|
|
132
|
+
}
|
|
133
|
+
}, {
|
|
134
|
+
key: "getLngLatBox",
|
|
135
|
+
value: function getLngLatBox() {
|
|
136
|
+
var _this$startEvent$lngL = this.startEvent.lngLat,
|
|
137
|
+
lng1 = _this$startEvent$lngL.lng,
|
|
138
|
+
lat1 = _this$startEvent$lngL.lat;
|
|
139
|
+
var _this$endEvent$lngLat = this.endEvent.lngLat,
|
|
140
|
+
lng2 = _this$endEvent$lngLat.lng,
|
|
141
|
+
lat2 = _this$endEvent$lngLat.lat;
|
|
142
|
+
return bbox(featureCollection([lineString([[lng1, lat1], [lng2, lat2]])]));
|
|
143
|
+
}
|
|
144
|
+
}]);
|
|
145
|
+
|
|
146
|
+
return BoxSelect;
|
|
147
|
+
}(EventEmitter);
|
|
148
|
+
|
|
149
|
+
export { BoxSelect as default };
|
package/es/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
25
25
|
private popupService;
|
|
26
26
|
private fontService;
|
|
27
27
|
private interactionService;
|
|
28
|
+
private boxSelect;
|
|
28
29
|
private container;
|
|
29
30
|
constructor(config: ISceneConfig);
|
|
30
31
|
get map(): unknown;
|
|
@@ -70,12 +71,13 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
70
71
|
addIconFontGlyphs(fontFamily: string, glyphs: IIconFontGlyph[]): void;
|
|
71
72
|
addControl(ctr: IControl): void;
|
|
72
73
|
removeControl(ctr: IControl): void;
|
|
73
|
-
getControlByName(name: string): IControl | undefined;
|
|
74
|
+
getControlByName(name: string): IControl<any> | undefined;
|
|
74
75
|
addMarker(marker: IMarker): void;
|
|
75
76
|
addMarkerLayer(layer: IMarkerLayer): void;
|
|
76
77
|
removeMarkerLayer(layer: IMarkerLayer): void;
|
|
77
78
|
removeAllMakers(): void;
|
|
78
79
|
addPopup(popup: IPopup): void;
|
|
80
|
+
removePopup(popup: IPopup): void;
|
|
79
81
|
on(type: string, handle: (...args: any[]) => void): void;
|
|
80
82
|
once(type: string, handle: (...args: any[]) => void): void;
|
|
81
83
|
emit(type: string, handle: (...args: any[]) => void): void;
|
|
@@ -106,6 +108,8 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
106
108
|
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>, name: string): void;
|
|
107
109
|
enableShaderPick(): void;
|
|
108
110
|
diasbleShaderPick(): void;
|
|
111
|
+
enableBoxSelect(once?: boolean): void;
|
|
112
|
+
disableBoxSelect(): void;
|
|
109
113
|
getPointSizeRange(): Float32Array;
|
|
110
114
|
private initComponent;
|
|
111
115
|
private initControl;
|
package/es/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createLayerContainer, createSceneContainer, SceneEventList, TYPES } fro
|
|
|
7
7
|
import { MaskLayer } from '@antv/l7-layers';
|
|
8
8
|
import { ReglRendererService } from '@antv/l7-renderer';
|
|
9
9
|
import { DOM, isMini } from '@antv/l7-utils';
|
|
10
|
+
import BoxSelect, { BoxSelectEventList } from "./boxSelect";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* 暴露 Scene API
|
|
@@ -45,6 +46,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
45
46
|
this.markerService = sceneContainer.get(TYPES.IMarkerService);
|
|
46
47
|
this.interactionService = sceneContainer.get(TYPES.IInteractionService);
|
|
47
48
|
this.popupService = sceneContainer.get(TYPES.IPopupService);
|
|
49
|
+
this.boxSelect = new BoxSelect(this, {
|
|
50
|
+
className: config.selectBoxClassName
|
|
51
|
+
});
|
|
48
52
|
|
|
49
53
|
if (isMini) {
|
|
50
54
|
this.sceneService.initMiniScene(config);
|
|
@@ -329,15 +333,36 @@ var Scene = /*#__PURE__*/function () {
|
|
|
329
333
|
value: function addPopup(popup) {
|
|
330
334
|
this.popupService.addPopup(popup);
|
|
331
335
|
}
|
|
336
|
+
}, {
|
|
337
|
+
key: "removePopup",
|
|
338
|
+
value: function removePopup(popup) {
|
|
339
|
+
this.popupService.removePopup(popup);
|
|
340
|
+
}
|
|
332
341
|
}, {
|
|
333
342
|
key: "on",
|
|
334
343
|
value: function on(type, handle) {
|
|
335
|
-
|
|
344
|
+
if (BoxSelectEventList.includes(type)) {
|
|
345
|
+
var _this$boxSelect;
|
|
346
|
+
|
|
347
|
+
(_this$boxSelect = this.boxSelect) === null || _this$boxSelect === void 0 ? void 0 : _this$boxSelect.on(type, handle);
|
|
348
|
+
} else if (SceneEventList.includes(type)) {
|
|
349
|
+
this.sceneService.on(type, handle);
|
|
350
|
+
} else {
|
|
351
|
+
this.mapService.on(type, handle);
|
|
352
|
+
}
|
|
336
353
|
}
|
|
337
354
|
}, {
|
|
338
355
|
key: "once",
|
|
339
356
|
value: function once(type, handle) {
|
|
340
|
-
|
|
357
|
+
if (BoxSelectEventList.includes(type)) {
|
|
358
|
+
var _this$boxSelect2;
|
|
359
|
+
|
|
360
|
+
(_this$boxSelect2 = this.boxSelect) === null || _this$boxSelect2 === void 0 ? void 0 : _this$boxSelect2.once(type, handle);
|
|
361
|
+
} else if (SceneEventList.includes(type)) {
|
|
362
|
+
this.sceneService.once(type, handle);
|
|
363
|
+
} else {
|
|
364
|
+
this.mapService.once(type, handle);
|
|
365
|
+
}
|
|
341
366
|
}
|
|
342
367
|
}, {
|
|
343
368
|
key: "emit",
|
|
@@ -347,7 +372,15 @@ var Scene = /*#__PURE__*/function () {
|
|
|
347
372
|
}, {
|
|
348
373
|
key: "off",
|
|
349
374
|
value: function off(type, handle) {
|
|
350
|
-
|
|
375
|
+
if (BoxSelectEventList.includes(type)) {
|
|
376
|
+
var _this$boxSelect3;
|
|
377
|
+
|
|
378
|
+
(_this$boxSelect3 = this.boxSelect) === null || _this$boxSelect3 === void 0 ? void 0 : _this$boxSelect3.off(type, handle);
|
|
379
|
+
} else if (SceneEventList.includes(type)) {
|
|
380
|
+
this.sceneService.off(type, handle);
|
|
381
|
+
} else {
|
|
382
|
+
this.mapService.off(type, handle);
|
|
383
|
+
}
|
|
351
384
|
} // implements IMapController
|
|
352
385
|
|
|
353
386
|
}, {
|
|
@@ -488,6 +521,25 @@ var Scene = /*#__PURE__*/function () {
|
|
|
488
521
|
key: "diasbleShaderPick",
|
|
489
522
|
value: function diasbleShaderPick() {
|
|
490
523
|
this.layerService.disableShaderPick();
|
|
524
|
+
}
|
|
525
|
+
}, {
|
|
526
|
+
key: "enableBoxSelect",
|
|
527
|
+
value: function enableBoxSelect() {
|
|
528
|
+
var _this4 = this;
|
|
529
|
+
|
|
530
|
+
var once = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
531
|
+
this.boxSelect.enable();
|
|
532
|
+
|
|
533
|
+
if (once) {
|
|
534
|
+
this.boxSelect.once('selectend', function () {
|
|
535
|
+
_this4.disableBoxSelect();
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}, {
|
|
540
|
+
key: "disableBoxSelect",
|
|
541
|
+
value: function disableBoxSelect() {
|
|
542
|
+
this.boxSelect.disable();
|
|
491
543
|
} // get current point size info
|
|
492
544
|
|
|
493
545
|
}, {
|
package/lib/boxSelect.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/boxSelect.ts
|
|
23
|
+
var boxSelect_exports = {};
|
|
24
|
+
__export(boxSelect_exports, {
|
|
25
|
+
BoxSelectEventList: () => BoxSelectEventList,
|
|
26
|
+
default: () => BoxSelect
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(boxSelect_exports);
|
|
29
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
30
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
31
|
+
var import_bbox = __toESM(require("@turf/bbox"));
|
|
32
|
+
var import_helpers = require("@turf/helpers");
|
|
33
|
+
var BoxSelectEventList = ["selectstart", "selecting", "selectend"];
|
|
34
|
+
var BoxSelect = class extends import_eventemitter3.EventEmitter {
|
|
35
|
+
constructor(scene, options = {}) {
|
|
36
|
+
super();
|
|
37
|
+
this.isEnable = false;
|
|
38
|
+
this.onDragStart = (e) => {
|
|
39
|
+
this.box.style.display = "block";
|
|
40
|
+
this.startEvent = this.endEvent = e;
|
|
41
|
+
this.syncBoxBound();
|
|
42
|
+
this.emit("selectstart", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
43
|
+
};
|
|
44
|
+
this.onDragging = (e) => {
|
|
45
|
+
this.endEvent = e;
|
|
46
|
+
this.syncBoxBound();
|
|
47
|
+
this.emit("selecting", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
48
|
+
};
|
|
49
|
+
this.onDragEnd = (e) => {
|
|
50
|
+
this.endEvent = e;
|
|
51
|
+
this.box.style.display = "none";
|
|
52
|
+
this.emit("selectend", this.getLngLatBox(), this.startEvent, this.endEvent);
|
|
53
|
+
};
|
|
54
|
+
this.scene = scene;
|
|
55
|
+
this.options = options;
|
|
56
|
+
}
|
|
57
|
+
get container() {
|
|
58
|
+
return this.scene.getMapService().getMarkerContainer();
|
|
59
|
+
}
|
|
60
|
+
enable() {
|
|
61
|
+
if (this.isEnable) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { className } = this.options;
|
|
65
|
+
this.scene.setMapStatus({
|
|
66
|
+
dragEnable: false
|
|
67
|
+
});
|
|
68
|
+
this.container.style.cursor = "crosshair";
|
|
69
|
+
if (!this.box) {
|
|
70
|
+
const box = import_l7_utils.DOM.create("div", void 0, this.container);
|
|
71
|
+
box.classList.add("l7-select-box");
|
|
72
|
+
if (className) {
|
|
73
|
+
box.classList.add(className);
|
|
74
|
+
}
|
|
75
|
+
box.style.display = "none";
|
|
76
|
+
this.box = box;
|
|
77
|
+
}
|
|
78
|
+
this.scene.on("dragstart", this.onDragStart);
|
|
79
|
+
this.scene.on("dragging", this.onDragging);
|
|
80
|
+
this.scene.on("dragend", this.onDragEnd);
|
|
81
|
+
this.isEnable = true;
|
|
82
|
+
}
|
|
83
|
+
disable() {
|
|
84
|
+
if (!this.isEnable) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
this.scene.setMapStatus({
|
|
88
|
+
dragEnable: true
|
|
89
|
+
});
|
|
90
|
+
this.container.style.cursor = "auto";
|
|
91
|
+
this.scene.off("dragstart", this.onDragStart);
|
|
92
|
+
this.scene.off("dragging", this.onDragging);
|
|
93
|
+
this.scene.off("dragend", this.onDragEnd);
|
|
94
|
+
this.isEnable = false;
|
|
95
|
+
}
|
|
96
|
+
syncBoxBound() {
|
|
97
|
+
const { x: x1, y: y1 } = this.startEvent;
|
|
98
|
+
const { x: x2, y: y2 } = this.endEvent;
|
|
99
|
+
const left = Math.min(x1, x2);
|
|
100
|
+
const top = Math.min(y1, y2);
|
|
101
|
+
const width = Math.abs(x1 - x2);
|
|
102
|
+
const height = Math.abs(y1 - y2);
|
|
103
|
+
this.box.style.top = `${top}px`;
|
|
104
|
+
this.box.style.left = `${left}px`;
|
|
105
|
+
this.box.style.width = `${width}px`;
|
|
106
|
+
this.box.style.height = `${height}px`;
|
|
107
|
+
}
|
|
108
|
+
getLngLatBox() {
|
|
109
|
+
const {
|
|
110
|
+
lngLat: { lng: lng1, lat: lat1 }
|
|
111
|
+
} = this.startEvent;
|
|
112
|
+
const {
|
|
113
|
+
lngLat: { lng: lng2, lat: lat2 }
|
|
114
|
+
} = this.endEvent;
|
|
115
|
+
return (0, import_bbox.default)((0, import_helpers.featureCollection)([
|
|
116
|
+
(0, import_helpers.lineString)([
|
|
117
|
+
[lng1, lat1],
|
|
118
|
+
[lng2, lat2]
|
|
119
|
+
])
|
|
120
|
+
]));
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
124
|
+
0 && (module.exports = {
|
|
125
|
+
BoxSelectEventList
|
|
126
|
+
});
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
7
|
var __export = (target, all) => {
|
|
6
8
|
for (var name in all)
|
|
@@ -14,6 +16,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
16
|
}
|
|
15
17
|
return to;
|
|
16
18
|
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
17
20
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
21
|
|
|
19
22
|
// src/index.ts
|
|
@@ -27,6 +30,7 @@ var import_l7_core = require("@antv/l7-core");
|
|
|
27
30
|
var import_l7_layers = require("@antv/l7-layers");
|
|
28
31
|
var import_l7_renderer = require("@antv/l7-renderer");
|
|
29
32
|
var import_l7_utils = require("@antv/l7-utils");
|
|
33
|
+
var import_boxSelect = __toESM(require("./boxSelect"));
|
|
30
34
|
var Scene = class {
|
|
31
35
|
constructor(config) {
|
|
32
36
|
const { id, map, canvas, hasBaseMap } = config;
|
|
@@ -43,6 +47,9 @@ var Scene = class {
|
|
|
43
47
|
this.markerService = sceneContainer.get(import_l7_core.TYPES.IMarkerService);
|
|
44
48
|
this.interactionService = sceneContainer.get(import_l7_core.TYPES.IInteractionService);
|
|
45
49
|
this.popupService = sceneContainer.get(import_l7_core.TYPES.IPopupService);
|
|
50
|
+
this.boxSelect = new import_boxSelect.default(this, {
|
|
51
|
+
className: config.selectBoxClassName
|
|
52
|
+
});
|
|
46
53
|
if (import_l7_utils.isMini) {
|
|
47
54
|
this.sceneService.initMiniScene(config);
|
|
48
55
|
} else {
|
|
@@ -213,17 +220,41 @@ var Scene = class {
|
|
|
213
220
|
addPopup(popup) {
|
|
214
221
|
this.popupService.addPopup(popup);
|
|
215
222
|
}
|
|
223
|
+
removePopup(popup) {
|
|
224
|
+
this.popupService.removePopup(popup);
|
|
225
|
+
}
|
|
216
226
|
on(type, handle) {
|
|
217
|
-
|
|
227
|
+
var _a;
|
|
228
|
+
if (import_boxSelect.BoxSelectEventList.includes(type)) {
|
|
229
|
+
(_a = this.boxSelect) == null ? void 0 : _a.on(type, handle);
|
|
230
|
+
} else if (import_l7_core.SceneEventList.includes(type)) {
|
|
231
|
+
this.sceneService.on(type, handle);
|
|
232
|
+
} else {
|
|
233
|
+
this.mapService.on(type, handle);
|
|
234
|
+
}
|
|
218
235
|
}
|
|
219
236
|
once(type, handle) {
|
|
220
|
-
|
|
237
|
+
var _a;
|
|
238
|
+
if (import_boxSelect.BoxSelectEventList.includes(type)) {
|
|
239
|
+
(_a = this.boxSelect) == null ? void 0 : _a.once(type, handle);
|
|
240
|
+
} else if (import_l7_core.SceneEventList.includes(type)) {
|
|
241
|
+
this.sceneService.once(type, handle);
|
|
242
|
+
} else {
|
|
243
|
+
this.mapService.once(type, handle);
|
|
244
|
+
}
|
|
221
245
|
}
|
|
222
246
|
emit(type, handle) {
|
|
223
247
|
import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.emit(type, handle);
|
|
224
248
|
}
|
|
225
249
|
off(type, handle) {
|
|
226
|
-
|
|
250
|
+
var _a;
|
|
251
|
+
if (import_boxSelect.BoxSelectEventList.includes(type)) {
|
|
252
|
+
(_a = this.boxSelect) == null ? void 0 : _a.off(type, handle);
|
|
253
|
+
} else if (import_l7_core.SceneEventList.includes(type)) {
|
|
254
|
+
this.sceneService.off(type, handle);
|
|
255
|
+
} else {
|
|
256
|
+
this.mapService.off(type, handle);
|
|
257
|
+
}
|
|
227
258
|
}
|
|
228
259
|
getZoom() {
|
|
229
260
|
return this.mapService.getZoom();
|
|
@@ -307,6 +338,17 @@ var Scene = class {
|
|
|
307
338
|
diasbleShaderPick() {
|
|
308
339
|
this.layerService.disableShaderPick();
|
|
309
340
|
}
|
|
341
|
+
enableBoxSelect(once = true) {
|
|
342
|
+
this.boxSelect.enable();
|
|
343
|
+
if (once) {
|
|
344
|
+
this.boxSelect.once("selectend", () => {
|
|
345
|
+
this.disableBoxSelect();
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
disableBoxSelect() {
|
|
350
|
+
this.boxSelect.disable();
|
|
351
|
+
}
|
|
310
352
|
getPointSizeRange() {
|
|
311
353
|
return this.sceneService.getPointSizeRange();
|
|
312
354
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-scene",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.36-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -23,21 +23,23 @@
|
|
|
23
23
|
"author": "xiaoiver",
|
|
24
24
|
"license": "ISC",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@antv/l7-component": "2.9.
|
|
27
|
-
"@antv/l7-core": "2.9.
|
|
28
|
-
"@antv/l7-layers": "2.9.
|
|
29
|
-
"@antv/l7-maps": "2.9.
|
|
30
|
-
"@antv/l7-renderer": "2.9.
|
|
31
|
-
"@antv/l7-utils": "2.9.
|
|
26
|
+
"@antv/l7-component": "2.9.36-alpha.1",
|
|
27
|
+
"@antv/l7-core": "2.9.36-alpha.1",
|
|
28
|
+
"@antv/l7-layers": "2.9.36-alpha.1",
|
|
29
|
+
"@antv/l7-maps": "2.9.36-alpha.1",
|
|
30
|
+
"@antv/l7-renderer": "2.9.36-alpha.1",
|
|
31
|
+
"@antv/l7-utils": "2.9.36-alpha.1",
|
|
32
32
|
"@babel/runtime": "^7.7.7",
|
|
33
|
+
"@turf/turf": "^6.5.0",
|
|
34
|
+
"eventemitter3": "^4.0.7",
|
|
33
35
|
"inversify": "^5.0.1",
|
|
34
36
|
"mapbox-gl": "^1.2.1",
|
|
35
37
|
"reflect-metadata": "^0.1.13"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
|
-
"@antv/l7-test-utils": "2.9.
|
|
40
|
+
"@antv/l7-test-utils": "2.9.36-alpha.1"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "dafb82e5eb2cf73db95d8dbdcef63d4ad5f99554",
|
|
41
43
|
"publishConfig": {
|
|
42
44
|
"access": "public"
|
|
43
45
|
}
|