@antv/l7-scene 2.25.5 → 2.25.7

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