@antv/l7-scene 2.9.37-alpha.2 → 2.9.37-alpha.3

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.
@@ -0,0 +1,119 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/boxSelect.ts
20
+ var boxSelect_exports = {};
21
+ __export(boxSelect_exports, {
22
+ BoxSelectEventList: () => BoxSelectEventList,
23
+ default: () => BoxSelect
24
+ });
25
+ module.exports = __toCommonJS(boxSelect_exports);
26
+ var import_l7_utils = require("@antv/l7-utils");
27
+ var import_eventemitter3 = require("eventemitter3");
28
+ var BoxSelectEventList = ["selectstart", "selecting", "selectend"];
29
+ var BoxSelect = class extends import_eventemitter3.EventEmitter {
30
+ constructor(scene, options = {}) {
31
+ super();
32
+ this.isEnable = false;
33
+ this.onDragStart = (e) => {
34
+ this.box.style.display = "block";
35
+ this.startEvent = this.endEvent = e;
36
+ this.syncBoxBound();
37
+ this.emit("selectstart", this.getLngLatBox(), this.startEvent, this.endEvent);
38
+ };
39
+ this.onDragging = (e) => {
40
+ this.endEvent = e;
41
+ this.syncBoxBound();
42
+ this.emit("selecting", this.getLngLatBox(), this.startEvent, this.endEvent);
43
+ };
44
+ this.onDragEnd = (e) => {
45
+ this.endEvent = e;
46
+ this.box.style.display = "none";
47
+ this.emit("selectend", this.getLngLatBox(), this.startEvent, this.endEvent);
48
+ };
49
+ this.scene = scene;
50
+ this.options = options;
51
+ }
52
+ get container() {
53
+ return this.scene.getMapService().getMarkerContainer();
54
+ }
55
+ enable() {
56
+ if (this.isEnable) {
57
+ return;
58
+ }
59
+ const { className } = this.options;
60
+ this.scene.setMapStatus({
61
+ dragEnable: false
62
+ });
63
+ this.container.style.cursor = "crosshair";
64
+ if (!this.box) {
65
+ const box = import_l7_utils.DOM.create("div", void 0, this.container);
66
+ box.classList.add("l7-select-box");
67
+ if (className) {
68
+ box.classList.add(className);
69
+ }
70
+ box.style.display = "none";
71
+ this.box = box;
72
+ }
73
+ this.scene.on("dragstart", this.onDragStart);
74
+ this.scene.on("dragging", this.onDragging);
75
+ this.scene.on("dragend", this.onDragEnd);
76
+ this.isEnable = true;
77
+ }
78
+ disable() {
79
+ if (!this.isEnable) {
80
+ return;
81
+ }
82
+ this.scene.setMapStatus({
83
+ dragEnable: true
84
+ });
85
+ this.container.style.cursor = "auto";
86
+ this.scene.off("dragstart", this.onDragStart);
87
+ this.scene.off("dragging", this.onDragging);
88
+ this.scene.off("dragend", this.onDragEnd);
89
+ this.isEnable = false;
90
+ }
91
+ syncBoxBound() {
92
+ const { x: x1, y: y1 } = this.startEvent;
93
+ const { x: x2, y: y2 } = this.endEvent;
94
+ const left = Math.min(x1, x2);
95
+ const top = Math.min(y1, y2);
96
+ const width = Math.abs(x1 - x2);
97
+ const height = Math.abs(y1 - y2);
98
+ this.box.style.top = `${top}px`;
99
+ this.box.style.left = `${left}px`;
100
+ this.box.style.width = `${width}px`;
101
+ this.box.style.height = `${height}px`;
102
+ }
103
+ getLngLatBox() {
104
+ const {
105
+ lngLat: { lng: lng1, lat: lat1 }
106
+ } = this.startEvent;
107
+ const {
108
+ lngLat: { lng: lng2, lat: lat2 }
109
+ } = this.endEvent;
110
+ return (0, import_l7_utils.getBBoxFromPoints)([
111
+ [lng1, lat1],
112
+ [lng2, lat2]
113
+ ]);
114
+ }
115
+ };
116
+ // Annotate the CommonJS export names for ESM import in node:
117
+ 0 && (module.exports = {
118
+ BoxSelectEventList
119
+ });
package/lib/index.js ADDED
@@ -0,0 +1,378 @@
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/index.ts
23
+ var src_exports = {};
24
+ __export(src_exports, {
25
+ Scene: () => Scene
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+ var import_l7_component = require("@antv/l7-component");
29
+ var import_l7_core = require("@antv/l7-core");
30
+ var import_l7_layers = require("@antv/l7-layers");
31
+ var import_l7_renderer = require("@antv/l7-renderer");
32
+ var import_l7_utils = require("@antv/l7-utils");
33
+ var import_boxSelect = __toESM(require("./boxSelect"));
34
+ var Scene = class {
35
+ constructor(config) {
36
+ const { id, map, canvas, hasBaseMap } = config;
37
+ const sceneContainer = (0, import_l7_core.createSceneContainer)();
38
+ this.container = sceneContainer;
39
+ map.setContainer(sceneContainer, id, canvas, hasBaseMap);
40
+ sceneContainer.bind(import_l7_core.TYPES.IRendererService).to(import_l7_renderer.ReglRendererService).inSingletonScope();
41
+ this.sceneService = sceneContainer.get(import_l7_core.TYPES.ISceneService);
42
+ this.mapService = sceneContainer.get(import_l7_core.TYPES.IMapService);
43
+ this.iconService = sceneContainer.get(import_l7_core.TYPES.IIconService);
44
+ this.fontService = sceneContainer.get(import_l7_core.TYPES.IFontService);
45
+ this.controlService = sceneContainer.get(import_l7_core.TYPES.IControlService);
46
+ this.layerService = sceneContainer.get(import_l7_core.TYPES.ILayerService);
47
+ this.markerService = sceneContainer.get(import_l7_core.TYPES.IMarkerService);
48
+ this.interactionService = sceneContainer.get(import_l7_core.TYPES.IInteractionService);
49
+ this.popupService = sceneContainer.get(import_l7_core.TYPES.IPopupService);
50
+ this.boxSelect = new import_boxSelect.default(this, {});
51
+ if (import_l7_utils.isMini) {
52
+ this.sceneService.initMiniScene(config);
53
+ } else {
54
+ this.initComponent(id);
55
+ this.sceneService.init(config);
56
+ this.initControl();
57
+ }
58
+ }
59
+ get map() {
60
+ return this.mapService.map;
61
+ }
62
+ get loaded() {
63
+ return this.sceneService.loaded;
64
+ }
65
+ getServiceContainer() {
66
+ return this.container;
67
+ }
68
+ getSize() {
69
+ return this.mapService.getSize();
70
+ }
71
+ getMinZoom() {
72
+ return this.mapService.getMinZoom();
73
+ }
74
+ getMaxZoom() {
75
+ return this.mapService.getMaxZoom();
76
+ }
77
+ getType() {
78
+ return this.mapService.getType();
79
+ }
80
+ getMapContainer() {
81
+ return this.mapService.getMapContainer();
82
+ }
83
+ getMapCanvasContainer() {
84
+ return this.mapService.getMapCanvasContainer();
85
+ }
86
+ getMapService() {
87
+ return this.mapService;
88
+ }
89
+ exportPng(type) {
90
+ return this.sceneService.exportPng(type);
91
+ }
92
+ exportMap(type) {
93
+ return this.sceneService.exportPng(type);
94
+ }
95
+ registerRenderService(render) {
96
+ if (this.sceneService.loaded) {
97
+ const renderSerivce = new render(this);
98
+ renderSerivce.init();
99
+ } else {
100
+ this.on("loaded", () => {
101
+ const renderSerivce = new render(this);
102
+ renderSerivce.init();
103
+ });
104
+ }
105
+ }
106
+ setBgColor(color) {
107
+ this.mapService.setBgColor(color);
108
+ }
109
+ addLayer(layer) {
110
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
111
+ layer.setContainer(layerContainer, this.container);
112
+ this.sceneService.addLayer(layer);
113
+ if (layer.inited) {
114
+ const maskInstance = this.initMask(layer);
115
+ this.addMask(maskInstance, layer.id);
116
+ } else {
117
+ layer.on("inited", () => {
118
+ const maskInstance = this.initMask(layer);
119
+ this.addMask(maskInstance, layer.id);
120
+ });
121
+ }
122
+ }
123
+ initMask(layer) {
124
+ const {
125
+ mask,
126
+ maskfence,
127
+ maskColor = "#000",
128
+ maskOpacity = 0
129
+ } = layer.getLayerConfig();
130
+ if (!mask)
131
+ return void 0;
132
+ const maskInstance = new import_l7_layers.MaskLayer().source(maskfence).shape("fill").style({
133
+ color: maskColor,
134
+ opacity: maskOpacity
135
+ });
136
+ return maskInstance;
137
+ }
138
+ addMask(mask, layerId) {
139
+ if (!mask)
140
+ return;
141
+ const parent = this.getLayer(layerId);
142
+ if (parent) {
143
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
144
+ mask.setContainer(layerContainer, this.container);
145
+ parent.addMaskLayer(mask);
146
+ this.sceneService.addLayer(mask);
147
+ } else {
148
+ console.warn("parent layer not find!");
149
+ }
150
+ }
151
+ getPickedLayer() {
152
+ return this.layerService.pickedLayerId;
153
+ }
154
+ getLayers() {
155
+ return this.layerService.getLayers();
156
+ }
157
+ getLayer(id) {
158
+ return this.layerService.getLayer(id);
159
+ }
160
+ getLayerByName(name) {
161
+ return this.layerService.getLayerByName(name);
162
+ }
163
+ removeLayer(layer, parentLayer) {
164
+ this.layerService.remove(layer, parentLayer);
165
+ }
166
+ removeAllLayer() {
167
+ this.layerService.removeAllLayers();
168
+ }
169
+ render() {
170
+ this.sceneService.render();
171
+ }
172
+ setEnableRender(flag) {
173
+ this.layerService.setEnableRender(flag);
174
+ }
175
+ addIconFont(name, fontUnicode) {
176
+ this.fontService.addIconFont(name, fontUnicode);
177
+ }
178
+ addIconFonts(options) {
179
+ options.forEach(([name, fontUnicode]) => {
180
+ this.fontService.addIconFont(name, fontUnicode);
181
+ });
182
+ }
183
+ addFontFace(fontFamily, fontPath) {
184
+ this.fontService.once("fontloaded", (e) => {
185
+ this.emit("fontloaded", e);
186
+ });
187
+ this.fontService.addFontFace(fontFamily, fontPath);
188
+ }
189
+ addImage(id, img) {
190
+ if (!import_l7_utils.isMini) {
191
+ this.iconService.addImage(id, img);
192
+ } else {
193
+ this.iconService.addImageMini(id, img, this.sceneService);
194
+ }
195
+ }
196
+ hasImage(id) {
197
+ return this.iconService.hasImage(id);
198
+ }
199
+ removeImage(id) {
200
+ this.iconService.removeImage(id);
201
+ }
202
+ addIconFontGlyphs(fontFamily, glyphs) {
203
+ this.fontService.addIconGlyphs(glyphs);
204
+ }
205
+ addControl(ctr) {
206
+ this.controlService.addControl(ctr, this.container);
207
+ }
208
+ removeControl(ctr) {
209
+ this.controlService.removeControl(ctr);
210
+ }
211
+ getControlByName(name) {
212
+ return this.controlService.getControlByName(name);
213
+ }
214
+ addMarker(marker) {
215
+ this.markerService.addMarker(marker);
216
+ }
217
+ addMarkerLayer(layer) {
218
+ this.markerService.addMarkerLayer(layer);
219
+ }
220
+ removeMarkerLayer(layer) {
221
+ this.markerService.removeMarkerLayer(layer);
222
+ }
223
+ removeAllMakers() {
224
+ this.markerService.removeAllMarkers();
225
+ }
226
+ addPopup(popup) {
227
+ this.popupService.addPopup(popup);
228
+ }
229
+ removePopup(popup) {
230
+ this.popupService.removePopup(popup);
231
+ }
232
+ on(type, handle) {
233
+ var _a;
234
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
235
+ (_a = this.boxSelect) == null ? void 0 : _a.on(type, handle);
236
+ } else if (import_l7_core.SceneEventList.includes(type)) {
237
+ this.sceneService.on(type, handle);
238
+ } else {
239
+ this.mapService.on(type, handle);
240
+ }
241
+ }
242
+ once(type, handle) {
243
+ var _a;
244
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
245
+ (_a = this.boxSelect) == null ? void 0 : _a.once(type, handle);
246
+ } else if (import_l7_core.SceneEventList.includes(type)) {
247
+ this.sceneService.once(type, handle);
248
+ } else {
249
+ this.mapService.once(type, handle);
250
+ }
251
+ }
252
+ emit(type, handle) {
253
+ import_l7_core.SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.emit(type, handle);
254
+ }
255
+ off(type, handle) {
256
+ var _a;
257
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
258
+ (_a = this.boxSelect) == null ? void 0 : _a.off(type, handle);
259
+ } else if (import_l7_core.SceneEventList.includes(type)) {
260
+ this.sceneService.off(type, handle);
261
+ } else {
262
+ this.mapService.off(type, handle);
263
+ }
264
+ }
265
+ getZoom() {
266
+ return this.mapService.getZoom();
267
+ }
268
+ getCenter(options) {
269
+ return this.mapService.getCenter(options);
270
+ }
271
+ setCenter(center, options) {
272
+ return this.mapService.setCenter(center, options);
273
+ }
274
+ getPitch() {
275
+ return this.mapService.getPitch();
276
+ }
277
+ setPitch(pitch) {
278
+ return this.mapService.setPitch(pitch);
279
+ }
280
+ getRotation() {
281
+ return this.mapService.getRotation();
282
+ }
283
+ getBounds() {
284
+ return this.mapService.getBounds();
285
+ }
286
+ setRotation(rotation) {
287
+ this.mapService.setRotation(rotation);
288
+ }
289
+ zoomIn() {
290
+ this.mapService.zoomIn();
291
+ }
292
+ zoomOut() {
293
+ this.mapService.zoomOut();
294
+ }
295
+ panTo(p) {
296
+ this.mapService.panTo(p);
297
+ }
298
+ panBy(x, y) {
299
+ this.mapService.panBy(x, y);
300
+ }
301
+ getContainer() {
302
+ return this.mapService.getContainer();
303
+ }
304
+ setZoom(zoom) {
305
+ this.mapService.setZoom(zoom);
306
+ }
307
+ fitBounds(bound, options) {
308
+ const { fitBoundsOptions, animate } = this.sceneService.getSceneConfig();
309
+ this.mapService.fitBounds(bound, options || {
310
+ ...fitBoundsOptions,
311
+ animate
312
+ });
313
+ }
314
+ setZoomAndCenter(zoom, center) {
315
+ this.mapService.setZoomAndCenter(zoom, center);
316
+ }
317
+ setMapStyle(style) {
318
+ this.mapService.setMapStyle(style);
319
+ }
320
+ setMapStatus(options) {
321
+ this.mapService.setMapStatus(options);
322
+ }
323
+ pixelToLngLat(pixel) {
324
+ return this.mapService.pixelToLngLat(pixel);
325
+ }
326
+ lngLatToPixel(lnglat) {
327
+ return this.mapService.lngLatToPixel(lnglat);
328
+ }
329
+ containerToLngLat(pixel) {
330
+ return this.mapService.containerToLngLat(pixel);
331
+ }
332
+ lngLatToContainer(lnglat) {
333
+ return this.mapService.lngLatToContainer(lnglat);
334
+ }
335
+ destroy() {
336
+ this.sceneService.destroy();
337
+ }
338
+ registerPostProcessingPass(constructor, name) {
339
+ this.container.bind(import_l7_core.TYPES.IPostProcessingPass).to(constructor).whenTargetNamed(name);
340
+ }
341
+ enableShaderPick() {
342
+ this.layerService.enableShaderPick();
343
+ }
344
+ diasbleShaderPick() {
345
+ this.layerService.disableShaderPick();
346
+ }
347
+ enableBoxSelect(once = true) {
348
+ this.boxSelect.enable();
349
+ if (once) {
350
+ this.boxSelect.once("selectend", () => {
351
+ this.disableBoxSelect();
352
+ });
353
+ }
354
+ }
355
+ disableBoxSelect() {
356
+ this.boxSelect.disable();
357
+ }
358
+ getPointSizeRange() {
359
+ return this.sceneService.getPointSizeRange();
360
+ }
361
+ initComponent(id) {
362
+ this.controlService.init({
363
+ container: import_l7_utils.DOM.getContainer(id)
364
+ }, this.container);
365
+ this.markerService.init(this.container);
366
+ this.popupService.init(this.container);
367
+ }
368
+ initControl() {
369
+ const { logoVisible, logoPosition } = this.sceneService.getSceneConfig();
370
+ if (logoVisible) {
371
+ this.addControl(new import_l7_component.Logo({ position: logoPosition }));
372
+ }
373
+ }
374
+ };
375
+ // Annotate the CommonJS export names for ESM import in node:
376
+ 0 && (module.exports = {
377
+ Scene
378
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-scene",
3
- "version": "2.9.37-alpha.2",
3
+ "version": "2.9.37-alpha.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -23,12 +23,12 @@
23
23
  "author": "xiaoiver",
24
24
  "license": "ISC",
25
25
  "dependencies": {
26
- "@antv/l7-component": "2.9.37-alpha.2",
27
- "@antv/l7-core": "2.9.37-alpha.2",
28
- "@antv/l7-layers": "2.9.37-alpha.2",
29
- "@antv/l7-maps": "2.9.37-alpha.2",
30
- "@antv/l7-renderer": "2.9.37-alpha.2",
31
- "@antv/l7-utils": "2.9.37-alpha.2",
26
+ "@antv/l7-component": "2.9.37-alpha.3",
27
+ "@antv/l7-core": "2.9.37-alpha.3",
28
+ "@antv/l7-layers": "2.9.37-alpha.3",
29
+ "@antv/l7-maps": "2.9.37-alpha.3",
30
+ "@antv/l7-renderer": "2.9.37-alpha.3",
31
+ "@antv/l7-utils": "2.9.37-alpha.3",
32
32
  "@babel/runtime": "^7.7.7",
33
33
  "eventemitter3": "^4.0.7",
34
34
  "inversify": "^5.0.1",
@@ -36,9 +36,9 @@
36
36
  "reflect-metadata": "^0.1.13"
37
37
  },
38
38
  "devDependencies": {
39
- "@antv/l7-test-utils": "2.9.37-alpha.2"
39
+ "@antv/l7-test-utils": "2.9.37-alpha.3"
40
40
  },
41
- "gitHead": "6820a389076688efdaedfe10d324ca5a7b5ae2f5",
41
+ "gitHead": "92f97e637cdeb05895909006e81ba45131154bf8",
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  }