@antv/l7-scene 2.25.7 → 2.25.10

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/lib/index.js ADDED
@@ -0,0 +1,516 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __defProps = Object.defineProperties;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
12
+ var __spreadValues = (a, b) => {
13
+ for (var prop in b || (b = {}))
14
+ if (__hasOwnProp.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ if (__getOwnPropSymbols)
17
+ for (var prop of __getOwnPropSymbols(b)) {
18
+ if (__propIsEnum.call(b, prop))
19
+ __defNormalProp(a, prop, b[prop]);
20
+ }
21
+ return a;
22
+ };
23
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
24
+ var __export = (target, all) => {
25
+ for (var name in all)
26
+ __defProp(target, name, { get: all[name], enumerable: true });
27
+ };
28
+ var __copyProps = (to, from, except, desc) => {
29
+ if (from && typeof from === "object" || typeof from === "function") {
30
+ for (let key of __getOwnPropNames(from))
31
+ if (!__hasOwnProp.call(to, key) && key !== except)
32
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
33
+ }
34
+ return to;
35
+ };
36
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
37
+ // If the importer is in node compatibility mode or this is not an ESM
38
+ // file that has been converted to a CommonJS file using a Babel-
39
+ // compatible transform (i.e. "__esModule" has not been set), then set
40
+ // "default" to the CommonJS "module.exports" for node compatibility.
41
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
42
+ mod
43
+ ));
44
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
+ var __async = (__this, __arguments, generator) => {
46
+ return new Promise((resolve, reject) => {
47
+ var fulfilled = (value) => {
48
+ try {
49
+ step(generator.next(value));
50
+ } catch (e) {
51
+ reject(e);
52
+ }
53
+ };
54
+ var rejected = (value) => {
55
+ try {
56
+ step(generator.throw(value));
57
+ } catch (e) {
58
+ reject(e);
59
+ }
60
+ };
61
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
62
+ step((generator = generator.apply(__this, __arguments)).next());
63
+ });
64
+ };
65
+
66
+ // src/index.ts
67
+ var src_exports = {};
68
+ __export(src_exports, {
69
+ Scene: () => Scene
70
+ });
71
+ module.exports = __toCommonJS(src_exports);
72
+ var import_l7_component = require("@antv/l7-component");
73
+ var import_l7_core = require("@antv/l7-core");
74
+ var import_l7_layers = require("@antv/l7-layers");
75
+ var import_l7_renderer = require("@antv/l7-renderer");
76
+ var import_l7_utils = require("@antv/l7-utils");
77
+ var import_boxSelect = __toESM(require("./boxSelect"));
78
+ var Scene = class {
79
+ constructor(config) {
80
+ const { id, map, renderer = "device" } = config;
81
+ const sceneContainer = (0, import_l7_core.createSceneContainer)();
82
+ this.container = sceneContainer;
83
+ map.setContainer(sceneContainer, id);
84
+ if (renderer === "regl") {
85
+ sceneContainer.rendererService = new import_l7_renderer.ReglRendererService();
86
+ } else {
87
+ sceneContainer.rendererService = new import_l7_renderer.DeviceRendererService();
88
+ }
89
+ this.sceneService = sceneContainer.sceneService;
90
+ this.mapService = sceneContainer.mapService;
91
+ this.iconService = sceneContainer.iconService;
92
+ this.fontService = sceneContainer.fontService;
93
+ this.controlService = sceneContainer.controlService;
94
+ this.layerService = sceneContainer.layerService;
95
+ this.debugService = sceneContainer.debugService;
96
+ this.debugService.setEnable(config.debug);
97
+ this.markerService = sceneContainer.markerService;
98
+ this.interactionService = sceneContainer.interactionService;
99
+ this.popupService = sceneContainer.popupService;
100
+ this.boxSelect = new import_boxSelect.default(this, {});
101
+ this.initComponent(id);
102
+ this.sceneService.init(config);
103
+ this.initControl();
104
+ }
105
+ get map() {
106
+ return this.mapService.map;
107
+ }
108
+ get loaded() {
109
+ return this.sceneService.loaded;
110
+ }
111
+ getServiceContainer() {
112
+ return this.container;
113
+ }
114
+ getSize() {
115
+ return this.mapService.getSize();
116
+ }
117
+ getMinZoom() {
118
+ return this.mapService.getMinZoom();
119
+ }
120
+ getMaxZoom() {
121
+ return this.mapService.getMaxZoom();
122
+ }
123
+ getType() {
124
+ return this.mapService.getType();
125
+ }
126
+ getMapContainer() {
127
+ return this.mapService.getMapContainer();
128
+ }
129
+ getMapCanvasContainer() {
130
+ return this.mapService.getMapCanvasContainer();
131
+ }
132
+ getMapService() {
133
+ return this.mapService;
134
+ }
135
+ /**
136
+ * 对外暴露 debugService
137
+ * @returns
138
+ */
139
+ getDebugService() {
140
+ return this.debugService;
141
+ }
142
+ exportPng(type) {
143
+ return __async(this, null, function* () {
144
+ return this.sceneService.exportPng(type);
145
+ });
146
+ }
147
+ exportMap(type) {
148
+ return __async(this, null, function* () {
149
+ return this.sceneService.exportPng(type);
150
+ });
151
+ }
152
+ registerRenderService(render) {
153
+ if (this.sceneService.loaded) {
154
+ const renderSerivce = new render(this);
155
+ renderSerivce.init();
156
+ } else {
157
+ this.on("loaded", () => {
158
+ const renderSerivce = new render(this);
159
+ renderSerivce.init();
160
+ });
161
+ }
162
+ }
163
+ setBgColor(color) {
164
+ this.mapService.setBgColor(color);
165
+ }
166
+ addLayer(layer) {
167
+ if (this.loaded) {
168
+ this.preAddLayer(layer);
169
+ } else {
170
+ this.once("loaded", () => {
171
+ this.preAddLayer(layer);
172
+ });
173
+ }
174
+ }
175
+ // layer 管理
176
+ preAddLayer(layer) {
177
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
178
+ layer.setContainer(layerContainer);
179
+ this.sceneService.addLayer(layer);
180
+ if (layer.inited) {
181
+ this.initTileLayer(layer);
182
+ const maskInstance = this.initMask(layer);
183
+ this.addMask(maskInstance, layer.id);
184
+ } else {
185
+ layer.on("inited", () => {
186
+ this.initTileLayer(layer);
187
+ const maskInstance = this.initMask(layer);
188
+ this.addMask(maskInstance, layer.id);
189
+ });
190
+ }
191
+ }
192
+ // 兼容历史接口
193
+ initMask(layer) {
194
+ const { mask, maskfence, maskColor = "#000", maskOpacity = 0 } = layer.getLayerConfig();
195
+ if (!mask || !maskfence) {
196
+ return void 0;
197
+ }
198
+ const maskInstance = new import_l7_layers.MaskLayer().source(maskfence).shape("fill").style({
199
+ color: maskColor,
200
+ opacity: maskOpacity
201
+ });
202
+ return maskInstance;
203
+ }
204
+ addMask(mask, layerId) {
205
+ if (!mask) {
206
+ return;
207
+ }
208
+ const parent = this.getLayer(layerId);
209
+ if (parent) {
210
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
211
+ mask.setContainer(layerContainer);
212
+ parent.addMaskLayer(mask);
213
+ this.sceneService.addMask(mask);
214
+ } else {
215
+ console.warn("parent layer not find!");
216
+ }
217
+ }
218
+ getPickedLayer() {
219
+ return this.layerService.pickedLayerId;
220
+ }
221
+ getLayers() {
222
+ return this.layerService.getLayers();
223
+ }
224
+ getLayer(id) {
225
+ return this.layerService.getLayer(id);
226
+ }
227
+ getLayerByName(name) {
228
+ return this.layerService.getLayerByName(name);
229
+ }
230
+ removeLayer(layer, parentLayer) {
231
+ return __async(this, null, function* () {
232
+ yield this.layerService.remove(layer, parentLayer);
233
+ });
234
+ }
235
+ removeAllLayer() {
236
+ return __async(this, null, function* () {
237
+ yield this.layerService.removeAllLayers();
238
+ });
239
+ }
240
+ render() {
241
+ this.sceneService.render();
242
+ }
243
+ setEnableRender(flag) {
244
+ this.layerService.setEnableRender(flag);
245
+ }
246
+ // asset method
247
+ /**
248
+ * 为 layer/point/text 支持 iconfont 模式支持
249
+ * @param fontUnicode
250
+ * @param name
251
+ */
252
+ addIconFont(name, fontUnicode) {
253
+ this.fontService.addIconFont(name, fontUnicode);
254
+ }
255
+ addIconFonts(options) {
256
+ options.forEach(([name, fontUnicode]) => {
257
+ this.fontService.addIconFont(name, fontUnicode);
258
+ });
259
+ }
260
+ /**
261
+ * 用户自定义添加第三方字体
262
+ * @param fontFamily
263
+ * @param fontPath
264
+ */
265
+ addFontFace(fontFamily, fontPath) {
266
+ this.fontService.once("fontloaded", (e) => {
267
+ this.emit("fontloaded", e);
268
+ });
269
+ this.fontService.addFontFace(fontFamily, fontPath);
270
+ }
271
+ addImage(id, img) {
272
+ return __async(this, null, function* () {
273
+ yield this.iconService.addImage(id, img);
274
+ });
275
+ }
276
+ hasImage(id) {
277
+ return this.iconService.hasImage(id);
278
+ }
279
+ removeImage(id) {
280
+ this.iconService.removeImage(id);
281
+ }
282
+ addIconFontGlyphs(fontFamily, glyphs) {
283
+ this.fontService.addIconGlyphs(glyphs);
284
+ }
285
+ // map control method
286
+ addControl(ctr) {
287
+ this.controlService.addControl(ctr, this.container);
288
+ }
289
+ removeControl(ctr) {
290
+ this.controlService.removeControl(ctr);
291
+ }
292
+ getControlByName(name) {
293
+ return this.controlService.getControlByName(name);
294
+ }
295
+ // marker
296
+ addMarker(marker) {
297
+ this.markerService.addMarker(marker);
298
+ }
299
+ addMarkerLayer(layer) {
300
+ this.markerService.addMarkerLayer(layer);
301
+ }
302
+ removeMarkerLayer(layer) {
303
+ this.markerService.removeMarkerLayer(layer);
304
+ }
305
+ removeAllMarkers() {
306
+ this.markerService.removeAllMarkers();
307
+ }
308
+ /**
309
+ * @deprecated 请使用 removeAllMarkers
310
+ */
311
+ removeAllMakers() {
312
+ console.warn("removeAllMakers 已废弃,请使用 removeAllMarkers");
313
+ this.markerService.removeAllMarkers();
314
+ }
315
+ addPopup(popup) {
316
+ this.popupService.addPopup(popup);
317
+ }
318
+ removePopup(popup) {
319
+ this.popupService.removePopup(popup);
320
+ }
321
+ on(type, handle) {
322
+ var _a;
323
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
324
+ (_a = this.boxSelect) == null ? void 0 : _a.on(type, handle);
325
+ } else if (import_l7_core.SceneEventList.includes(type)) {
326
+ this.sceneService.on(type, handle);
327
+ } else {
328
+ this.mapService.on(type, handle);
329
+ }
330
+ }
331
+ once(type, handle) {
332
+ var _a;
333
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
334
+ (_a = this.boxSelect) == null ? void 0 : _a.once(type, handle);
335
+ } else if (import_l7_core.SceneEventList.includes(type)) {
336
+ this.sceneService.once(type, handle);
337
+ } else {
338
+ this.mapService.once(type, handle);
339
+ }
340
+ }
341
+ emit(type, ...args) {
342
+ if (import_l7_core.SceneEventList.includes(type)) {
343
+ this.sceneService.emit(type, ...args);
344
+ } else {
345
+ this.mapService.emit(type, ...args);
346
+ }
347
+ }
348
+ off(type, handle) {
349
+ var _a;
350
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
351
+ (_a = this.boxSelect) == null ? void 0 : _a.off(type, handle);
352
+ } else if (import_l7_core.SceneEventList.includes(type)) {
353
+ this.sceneService.off(type, handle);
354
+ } else {
355
+ this.mapService.off(type, handle);
356
+ }
357
+ }
358
+ // implements IMapController
359
+ getZoom() {
360
+ return this.mapService.getZoom();
361
+ }
362
+ getCenter(options) {
363
+ return this.mapService.getCenter(options);
364
+ }
365
+ setCenter(center, options) {
366
+ return this.mapService.setCenter(center, options);
367
+ }
368
+ getPitch() {
369
+ return this.mapService.getPitch();
370
+ }
371
+ setPitch(pitch) {
372
+ return this.mapService.setPitch(pitch);
373
+ }
374
+ getRotation() {
375
+ return this.mapService.getRotation();
376
+ }
377
+ getBounds() {
378
+ return this.mapService.getBounds();
379
+ }
380
+ setRotation(rotation) {
381
+ this.mapService.setRotation(rotation);
382
+ }
383
+ zoomIn() {
384
+ this.mapService.zoomIn();
385
+ }
386
+ zoomOut() {
387
+ this.mapService.zoomOut();
388
+ }
389
+ panTo(p) {
390
+ this.mapService.panTo(p);
391
+ }
392
+ panBy(x, y) {
393
+ this.mapService.panBy(x, y);
394
+ }
395
+ getContainer() {
396
+ return this.mapService.getContainer();
397
+ }
398
+ setZoom(zoom) {
399
+ this.mapService.setZoom(zoom);
400
+ }
401
+ fitBounds(bound, options) {
402
+ const { fitBoundsOptions, animate } = this.sceneService.getSceneConfig();
403
+ this.mapService.fitBounds(
404
+ bound,
405
+ // 选项优先级:用户传入,覆盖animate直接配置,覆盖Scene配置项传入
406
+ options || __spreadProps(__spreadValues({}, fitBoundsOptions), {
407
+ animate
408
+ })
409
+ );
410
+ }
411
+ setZoomAndCenter(zoom, center) {
412
+ this.mapService.setZoomAndCenter(zoom, center);
413
+ }
414
+ setMapStyle(style) {
415
+ this.mapService.setMapStyle(style);
416
+ }
417
+ setMapStatus(options) {
418
+ this.mapService.setMapStatus(options);
419
+ }
420
+ // conversion Method
421
+ pixelToLngLat(pixel) {
422
+ return this.mapService.pixelToLngLat(pixel);
423
+ }
424
+ lngLatToPixel(lnglat) {
425
+ return this.mapService.lngLatToPixel(lnglat);
426
+ }
427
+ containerToLngLat(pixel) {
428
+ return this.mapService.containerToLngLat(pixel);
429
+ }
430
+ lngLatToContainer(lnglat) {
431
+ return this.mapService.lngLatToContainer(lnglat);
432
+ }
433
+ destroy() {
434
+ this.sceneService.destroy();
435
+ }
436
+ /**
437
+ * 注册自定义后处理效果
438
+ * @param constructor 后处理效果构造函数
439
+ * @param name 后处理效果名称,便于在 Layer 中引用
440
+ */
441
+ registerPostProcessingPass(constructor, name) {
442
+ const instance = new constructor();
443
+ instance.setName(name);
444
+ this.container.postProcessingPass[name] = instance;
445
+ }
446
+ // 控制 shader pick 计算
447
+ enableShaderPick() {
448
+ this.layerService.enableShaderPick();
449
+ }
450
+ disableShaderPick() {
451
+ this.layerService.disableShaderPick();
452
+ }
453
+ /**
454
+ * @deprecated 请使用 disableShaderPick
455
+ */
456
+ diasbleShaderPick() {
457
+ console.warn("diasbleShaderPick 已废弃,请使用 disableShaderPick");
458
+ this.layerService.disableShaderPick();
459
+ }
460
+ enableBoxSelect(once = true) {
461
+ this.boxSelect.enable();
462
+ if (once) {
463
+ this.boxSelect.once("selectend", () => {
464
+ this.disableBoxSelect();
465
+ });
466
+ }
467
+ }
468
+ disableBoxSelect() {
469
+ this.boxSelect.disable();
470
+ }
471
+ // 数据协议
472
+ static addProtocol(protocol, handler) {
473
+ import_l7_utils.SceneConifg.REGISTERED_PROTOCOLS[protocol] = handler;
474
+ }
475
+ static removeProtocol(protocol) {
476
+ delete import_l7_utils.SceneConifg.REGISTERED_PROTOCOLS[protocol];
477
+ }
478
+ getProtocol(protocol) {
479
+ return import_l7_utils.SceneConifg.REGISTERED_PROTOCOLS[protocol];
480
+ }
481
+ startAnimate() {
482
+ this.layerService.startAnimate();
483
+ }
484
+ stopAnimate() {
485
+ this.layerService.stopAnimate();
486
+ }
487
+ // get current point size info
488
+ getPointSizeRange() {
489
+ return this.sceneService.getPointSizeRange();
490
+ }
491
+ initComponent(id) {
492
+ this.controlService.init(
493
+ {
494
+ container: import_l7_utils.DOM.getContainer(id)
495
+ },
496
+ this.container
497
+ );
498
+ this.markerService.init(this.container);
499
+ this.popupService.init(this.container);
500
+ }
501
+ initControl() {
502
+ const { logoVisible, logoPosition } = this.sceneService.getSceneConfig();
503
+ if (logoVisible) {
504
+ this.addControl(new import_l7_component.Logo({ position: logoPosition }));
505
+ }
506
+ }
507
+ initTileLayer(layer) {
508
+ if (layer.getSource().isTile) {
509
+ layer.tileLayer = new import_l7_layers.TileLayer(layer);
510
+ }
511
+ }
512
+ };
513
+ // Annotate the CommonJS export names for ESM import in node:
514
+ 0 && (module.exports = {
515
+ Scene
516
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-scene",
3
- "version": "2.25.7",
3
+ "version": "2.25.10",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": "https://github.com/orgs/antvis/people",
@@ -15,15 +15,15 @@
15
15
  "dependencies": {
16
16
  "@babel/runtime": "^7.7.7",
17
17
  "eventemitter3": "^4.0.7",
18
- "@antv/l7-core": "2.25.7",
19
- "@antv/l7-maps": "2.25.7",
20
- "@antv/l7-renderer": "2.25.7",
21
- "@antv/l7-utils": "2.25.7",
22
- "@antv/l7-component": "2.25.7",
23
- "@antv/l7-layers": "2.25.7"
18
+ "@antv/l7-component": "2.25.10",
19
+ "@antv/l7-maps": "2.25.10",
20
+ "@antv/l7-layers": "2.25.10",
21
+ "@antv/l7-core": "2.25.10",
22
+ "@antv/l7-renderer": "2.25.10",
23
+ "@antv/l7-utils": "2.25.10"
24
24
  },
25
25
  "devDependencies": {
26
- "@antv/l7-test-utils": "^2.25.7"
26
+ "@antv/l7-test-utils": "^2.25.10"
27
27
  },
28
28
  "publishConfig": {
29
29
  "access": "public",