@antv/l7-scene 2.9.36-alpha.1 → 2.9.37
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/index.d.ts +2 -5
- package/es/index.js +38 -79
- package/lib/index.js +27 -61
- package/package.json +9 -11
- package/es/boxSelect.d.ts +0 -23
- package/es/boxSelect.js +0 -149
- package/lib/boxSelect.js +0 -126
package/es/index.d.ts
CHANGED
|
@@ -25,7 +25,6 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
25
25
|
private popupService;
|
|
26
26
|
private fontService;
|
|
27
27
|
private interactionService;
|
|
28
|
-
private boxSelect;
|
|
29
28
|
private container;
|
|
30
29
|
constructor(config: ISceneConfig);
|
|
31
30
|
get map(): unknown;
|
|
@@ -43,6 +42,7 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
43
42
|
registerRenderService(render: any): void;
|
|
44
43
|
setBgColor(color: string): void;
|
|
45
44
|
addLayer(layer: ILayer): void;
|
|
45
|
+
initMask(layer: ILayer): ILayer | undefined;
|
|
46
46
|
addMask(mask: ILayer, layerId: string): void;
|
|
47
47
|
getPickedLayer(): number;
|
|
48
48
|
getLayers(): ILayer[];
|
|
@@ -71,13 +71,12 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
71
71
|
addIconFontGlyphs(fontFamily: string, glyphs: IIconFontGlyph[]): void;
|
|
72
72
|
addControl(ctr: IControl): void;
|
|
73
73
|
removeControl(ctr: IControl): void;
|
|
74
|
-
getControlByName(name: string): IControl
|
|
74
|
+
getControlByName(name: string): IControl | undefined;
|
|
75
75
|
addMarker(marker: IMarker): void;
|
|
76
76
|
addMarkerLayer(layer: IMarkerLayer): void;
|
|
77
77
|
removeMarkerLayer(layer: IMarkerLayer): void;
|
|
78
78
|
removeAllMakers(): void;
|
|
79
79
|
addPopup(popup: IPopup): void;
|
|
80
|
-
removePopup(popup: IPopup): void;
|
|
81
80
|
on(type: string, handle: (...args: any[]) => void): void;
|
|
82
81
|
once(type: string, handle: (...args: any[]) => void): void;
|
|
83
82
|
emit(type: string, handle: (...args: any[]) => void): void;
|
|
@@ -108,8 +107,6 @@ declare class Scene implements IPostProcessingPassPluggable, IMapController, ILa
|
|
|
108
107
|
registerPostProcessingPass(constructor: new (...args: any[]) => IPostProcessingPass<unknown>, name: string): void;
|
|
109
108
|
enableShaderPick(): void;
|
|
110
109
|
diasbleShaderPick(): void;
|
|
111
|
-
enableBoxSelect(once?: boolean): void;
|
|
112
|
-
disableBoxSelect(): void;
|
|
113
110
|
getPointSizeRange(): Float32Array;
|
|
114
111
|
private initComponent;
|
|
115
112
|
private initControl;
|
package/es/index.js
CHANGED
|
@@ -7,7 +7,6 @@ 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";
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* 暴露 Scene API
|
|
@@ -46,9 +45,6 @@ var Scene = /*#__PURE__*/function () {
|
|
|
46
45
|
this.markerService = sceneContainer.get(TYPES.IMarkerService);
|
|
47
46
|
this.interactionService = sceneContainer.get(TYPES.IInteractionService);
|
|
48
47
|
this.popupService = sceneContainer.get(TYPES.IPopupService);
|
|
49
|
-
this.boxSelect = new BoxSelect(this, {
|
|
50
|
-
className: config.selectBoxClassName
|
|
51
|
-
});
|
|
52
48
|
|
|
53
49
|
if (isMini) {
|
|
54
50
|
this.sceneService.initMiniScene(config);
|
|
@@ -145,36 +141,47 @@ var Scene = /*#__PURE__*/function () {
|
|
|
145
141
|
}, {
|
|
146
142
|
key: "addLayer",
|
|
147
143
|
value: function addLayer(layer) {
|
|
144
|
+
var _this2 = this;
|
|
145
|
+
|
|
148
146
|
// 为当前图层创建一个容器
|
|
149
147
|
// TODO: 初始化的时候设置 容器
|
|
150
148
|
var layerContainer = createLayerContainer(this.container);
|
|
151
149
|
layer.setContainer(layerContainer, this.container);
|
|
152
|
-
this.sceneService.addLayer(layer);
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
var mask = layerConfig.mask,
|
|
158
|
-
maskfence = layerConfig.maskfence,
|
|
159
|
-
_layerConfig$maskColo = layerConfig.maskColor,
|
|
160
|
-
maskColor = _layerConfig$maskColo === void 0 ? '#000' : _layerConfig$maskColo,
|
|
161
|
-
_layerConfig$maskOpac = layerConfig.maskOpacity,
|
|
162
|
-
maskOpacity = _layerConfig$maskOpac === void 0 ? 0 : _layerConfig$maskOpac;
|
|
163
|
-
|
|
164
|
-
if (mask && maskfence) {
|
|
165
|
-
var maskInstance = new MaskLayer().source(maskfence).shape('fill').style({
|
|
166
|
-
color: maskColor,
|
|
167
|
-
opacity: maskOpacity
|
|
168
|
-
});
|
|
169
|
-
this.addMask(maskInstance, layer.id);
|
|
170
|
-
}
|
|
150
|
+
this.sceneService.addLayer(layer); // mask 在 scene loaded 之后执行
|
|
151
|
+
|
|
152
|
+
if (layer.inited) {
|
|
153
|
+
var maskInstance = this.initMask(layer);
|
|
154
|
+
this.addMask(maskInstance, layer.id);
|
|
171
155
|
} else {
|
|
172
|
-
|
|
156
|
+
layer.on('inited', function () {
|
|
157
|
+
var maskInstance = _this2.initMask(layer);
|
|
158
|
+
|
|
159
|
+
_this2.addMask(maskInstance, layer.id);
|
|
160
|
+
});
|
|
173
161
|
}
|
|
174
162
|
}
|
|
163
|
+
}, {
|
|
164
|
+
key: "initMask",
|
|
165
|
+
value: function initMask(layer) {
|
|
166
|
+
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
167
|
+
mask = _layer$getLayerConfig.mask,
|
|
168
|
+
maskfence = _layer$getLayerConfig.maskfence,
|
|
169
|
+
_layer$getLayerConfig2 = _layer$getLayerConfig.maskColor,
|
|
170
|
+
maskColor = _layer$getLayerConfig2 === void 0 ? '#000' : _layer$getLayerConfig2,
|
|
171
|
+
_layer$getLayerConfig3 = _layer$getLayerConfig.maskOpacity,
|
|
172
|
+
maskOpacity = _layer$getLayerConfig3 === void 0 ? 0 : _layer$getLayerConfig3;
|
|
173
|
+
|
|
174
|
+
if (!mask) return undefined;
|
|
175
|
+
var maskInstance = new MaskLayer().source(maskfence).shape('fill').style({
|
|
176
|
+
color: maskColor,
|
|
177
|
+
opacity: maskOpacity
|
|
178
|
+
});
|
|
179
|
+
return maskInstance;
|
|
180
|
+
}
|
|
175
181
|
}, {
|
|
176
182
|
key: "addMask",
|
|
177
183
|
value: function addMask(mask, layerId) {
|
|
184
|
+
if (!mask) return;
|
|
178
185
|
var parent = this.getLayer(layerId);
|
|
179
186
|
|
|
180
187
|
if (parent) {
|
|
@@ -241,14 +248,14 @@ var Scene = /*#__PURE__*/function () {
|
|
|
241
248
|
}, {
|
|
242
249
|
key: "addIconFonts",
|
|
243
250
|
value: function addIconFonts(options) {
|
|
244
|
-
var
|
|
251
|
+
var _this3 = this;
|
|
245
252
|
|
|
246
253
|
options.forEach(function (_ref) {
|
|
247
254
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
248
255
|
name = _ref2[0],
|
|
249
256
|
fontUnicode = _ref2[1];
|
|
250
257
|
|
|
251
|
-
|
|
258
|
+
_this3.fontService.addIconFont(name, fontUnicode);
|
|
252
259
|
});
|
|
253
260
|
}
|
|
254
261
|
/**
|
|
@@ -260,10 +267,10 @@ var Scene = /*#__PURE__*/function () {
|
|
|
260
267
|
}, {
|
|
261
268
|
key: "addFontFace",
|
|
262
269
|
value: function addFontFace(fontFamily, fontPath) {
|
|
263
|
-
var
|
|
270
|
+
var _this4 = this;
|
|
264
271
|
|
|
265
272
|
this.fontService.once('fontloaded', function (e) {
|
|
266
|
-
|
|
273
|
+
_this4.emit('fontloaded', e);
|
|
267
274
|
});
|
|
268
275
|
this.fontService.addFontFace(fontFamily, fontPath);
|
|
269
276
|
}
|
|
@@ -333,36 +340,15 @@ var Scene = /*#__PURE__*/function () {
|
|
|
333
340
|
value: function addPopup(popup) {
|
|
334
341
|
this.popupService.addPopup(popup);
|
|
335
342
|
}
|
|
336
|
-
}, {
|
|
337
|
-
key: "removePopup",
|
|
338
|
-
value: function removePopup(popup) {
|
|
339
|
-
this.popupService.removePopup(popup);
|
|
340
|
-
}
|
|
341
343
|
}, {
|
|
342
344
|
key: "on",
|
|
343
345
|
value: function on(type, handle) {
|
|
344
|
-
|
|
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
|
-
}
|
|
346
|
+
SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.on(type, handle);
|
|
353
347
|
}
|
|
354
348
|
}, {
|
|
355
349
|
key: "once",
|
|
356
350
|
value: function once(type, handle) {
|
|
357
|
-
|
|
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
|
-
}
|
|
351
|
+
SceneEventList.indexOf(type) === -1 ? this.mapService.once(type, handle) : this.sceneService.once(type, handle);
|
|
366
352
|
}
|
|
367
353
|
}, {
|
|
368
354
|
key: "emit",
|
|
@@ -372,15 +358,7 @@ var Scene = /*#__PURE__*/function () {
|
|
|
372
358
|
}, {
|
|
373
359
|
key: "off",
|
|
374
360
|
value: function off(type, handle) {
|
|
375
|
-
|
|
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
|
-
}
|
|
361
|
+
SceneEventList.indexOf(type) === -1 ? this.mapService.off(type, handle) : this.sceneService.off(type, handle);
|
|
384
362
|
} // implements IMapController
|
|
385
363
|
|
|
386
364
|
}, {
|
|
@@ -521,25 +499,6 @@ var Scene = /*#__PURE__*/function () {
|
|
|
521
499
|
key: "diasbleShaderPick",
|
|
522
500
|
value: function diasbleShaderPick() {
|
|
523
501
|
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();
|
|
543
502
|
} // get current point size info
|
|
544
503
|
|
|
545
504
|
}, {
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
1
|
var __defProp = Object.defineProperty;
|
|
3
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
5
|
var __export = (target, all) => {
|
|
8
6
|
for (var name in all)
|
|
@@ -16,7 +14,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
14
|
}
|
|
17
15
|
return to;
|
|
18
16
|
};
|
|
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
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
18
|
|
|
22
19
|
// src/index.ts
|
|
@@ -30,7 +27,6 @@ var import_l7_core = require("@antv/l7-core");
|
|
|
30
27
|
var import_l7_layers = require("@antv/l7-layers");
|
|
31
28
|
var import_l7_renderer = require("@antv/l7-renderer");
|
|
32
29
|
var import_l7_utils = require("@antv/l7-utils");
|
|
33
|
-
var import_boxSelect = __toESM(require("./boxSelect"));
|
|
34
30
|
var Scene = class {
|
|
35
31
|
constructor(config) {
|
|
36
32
|
const { id, map, canvas, hasBaseMap } = config;
|
|
@@ -47,9 +43,6 @@ var Scene = class {
|
|
|
47
43
|
this.markerService = sceneContainer.get(import_l7_core.TYPES.IMarkerService);
|
|
48
44
|
this.interactionService = sceneContainer.get(import_l7_core.TYPES.IInteractionService);
|
|
49
45
|
this.popupService = sceneContainer.get(import_l7_core.TYPES.IPopupService);
|
|
50
|
-
this.boxSelect = new import_boxSelect.default(this, {
|
|
51
|
-
className: config.selectBoxClassName
|
|
52
|
-
});
|
|
53
46
|
if (import_l7_utils.isMini) {
|
|
54
47
|
this.sceneService.initMiniScene(config);
|
|
55
48
|
} else {
|
|
@@ -112,26 +105,34 @@ var Scene = class {
|
|
|
112
105
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
113
106
|
layer.setContainer(layerContainer, this.container);
|
|
114
107
|
this.sceneService.addLayer(layer);
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
mask,
|
|
119
|
-
maskfence,
|
|
120
|
-
maskColor = "#000",
|
|
121
|
-
maskOpacity = 0
|
|
122
|
-
} = layerConfig;
|
|
123
|
-
if (mask && maskfence) {
|
|
124
|
-
const maskInstance = new import_l7_layers.MaskLayer().source(maskfence).shape("fill").style({
|
|
125
|
-
color: maskColor,
|
|
126
|
-
opacity: maskOpacity
|
|
127
|
-
});
|
|
128
|
-
this.addMask(maskInstance, layer.id);
|
|
129
|
-
}
|
|
108
|
+
if (layer.inited) {
|
|
109
|
+
const maskInstance = this.initMask(layer);
|
|
110
|
+
this.addMask(maskInstance, layer.id);
|
|
130
111
|
} else {
|
|
131
|
-
|
|
112
|
+
layer.on("inited", () => {
|
|
113
|
+
const maskInstance = this.initMask(layer);
|
|
114
|
+
this.addMask(maskInstance, layer.id);
|
|
115
|
+
});
|
|
132
116
|
}
|
|
133
117
|
}
|
|
118
|
+
initMask(layer) {
|
|
119
|
+
const {
|
|
120
|
+
mask,
|
|
121
|
+
maskfence,
|
|
122
|
+
maskColor = "#000",
|
|
123
|
+
maskOpacity = 0
|
|
124
|
+
} = layer.getLayerConfig();
|
|
125
|
+
if (!mask)
|
|
126
|
+
return void 0;
|
|
127
|
+
const maskInstance = new import_l7_layers.MaskLayer().source(maskfence).shape("fill").style({
|
|
128
|
+
color: maskColor,
|
|
129
|
+
opacity: maskOpacity
|
|
130
|
+
});
|
|
131
|
+
return maskInstance;
|
|
132
|
+
}
|
|
134
133
|
addMask(mask, layerId) {
|
|
134
|
+
if (!mask)
|
|
135
|
+
return;
|
|
135
136
|
const parent = this.getLayer(layerId);
|
|
136
137
|
if (parent) {
|
|
137
138
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
@@ -220,41 +221,17 @@ var Scene = class {
|
|
|
220
221
|
addPopup(popup) {
|
|
221
222
|
this.popupService.addPopup(popup);
|
|
222
223
|
}
|
|
223
|
-
removePopup(popup) {
|
|
224
|
-
this.popupService.removePopup(popup);
|
|
225
|
-
}
|
|
226
224
|
on(type, handle) {
|
|
227
|
-
|
|
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
|
-
}
|
|
225
|
+
import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.on(type, handle);
|
|
235
226
|
}
|
|
236
227
|
once(type, handle) {
|
|
237
|
-
|
|
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
|
-
}
|
|
228
|
+
import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.once(type, handle) : this.sceneService.once(type, handle);
|
|
245
229
|
}
|
|
246
230
|
emit(type, handle) {
|
|
247
231
|
import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.emit(type, handle);
|
|
248
232
|
}
|
|
249
233
|
off(type, handle) {
|
|
250
|
-
|
|
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
|
-
}
|
|
234
|
+
import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.off(type, handle) : this.sceneService.off(type, handle);
|
|
258
235
|
}
|
|
259
236
|
getZoom() {
|
|
260
237
|
return this.mapService.getZoom();
|
|
@@ -338,17 +315,6 @@ var Scene = class {
|
|
|
338
315
|
diasbleShaderPick() {
|
|
339
316
|
this.layerService.disableShaderPick();
|
|
340
317
|
}
|
|
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
|
-
}
|
|
352
318
|
getPointSizeRange() {
|
|
353
319
|
return this.sceneService.getPointSizeRange();
|
|
354
320
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-scene",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.37",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -23,23 +23,21 @@
|
|
|
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.37",
|
|
27
|
+
"@antv/l7-core": "2.9.37",
|
|
28
|
+
"@antv/l7-layers": "2.9.37",
|
|
29
|
+
"@antv/l7-maps": "2.9.37",
|
|
30
|
+
"@antv/l7-renderer": "2.9.37",
|
|
31
|
+
"@antv/l7-utils": "2.9.37",
|
|
32
32
|
"@babel/runtime": "^7.7.7",
|
|
33
|
-
"@turf/turf": "^6.5.0",
|
|
34
|
-
"eventemitter3": "^4.0.7",
|
|
35
33
|
"inversify": "^5.0.1",
|
|
36
34
|
"mapbox-gl": "^1.2.1",
|
|
37
35
|
"reflect-metadata": "^0.1.13"
|
|
38
36
|
},
|
|
39
37
|
"devDependencies": {
|
|
40
|
-
"@antv/l7-test-utils": "2.9.
|
|
38
|
+
"@antv/l7-test-utils": "2.9.37"
|
|
41
39
|
},
|
|
42
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "18d479150376cbcb0d616f921036173460293c38",
|
|
43
41
|
"publishConfig": {
|
|
44
42
|
"access": "public"
|
|
45
43
|
}
|
package/es/boxSelect.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
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/lib/boxSelect.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
});
|