@antv/l7-scene 2.9.32-alpha.3 → 2.9.32-alpha.4

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,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 ADDED
@@ -0,0 +1,366 @@
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
+ className: config.selectBoxClassName
52
+ });
53
+ if (import_l7_utils.isMini) {
54
+ this.sceneService.initMiniScene(config);
55
+ } else {
56
+ this.initComponent(id);
57
+ this.sceneService.init(config);
58
+ this.initControl();
59
+ }
60
+ }
61
+ get map() {
62
+ return this.mapService.map;
63
+ }
64
+ get loaded() {
65
+ return this.sceneService.loaded;
66
+ }
67
+ getServiceContainer() {
68
+ return this.container;
69
+ }
70
+ getSize() {
71
+ return this.mapService.getSize();
72
+ }
73
+ getMinZoom() {
74
+ return this.mapService.getMinZoom();
75
+ }
76
+ getMaxZoom() {
77
+ return this.mapService.getMaxZoom();
78
+ }
79
+ getType() {
80
+ return this.mapService.getType();
81
+ }
82
+ getMapContainer() {
83
+ return this.mapService.getMapContainer();
84
+ }
85
+ getMapCanvasContainer() {
86
+ return this.mapService.getMapCanvasContainer();
87
+ }
88
+ getMapService() {
89
+ return this.mapService;
90
+ }
91
+ exportPng(type) {
92
+ return this.sceneService.exportPng(type);
93
+ }
94
+ exportMap(type) {
95
+ return this.sceneService.exportPng(type);
96
+ }
97
+ registerRenderService(render) {
98
+ if (this.sceneService.loaded) {
99
+ const renderSerivce = new render(this);
100
+ renderSerivce.init();
101
+ } else {
102
+ this.on("loaded", () => {
103
+ const renderSerivce = new render(this);
104
+ renderSerivce.init();
105
+ });
106
+ }
107
+ }
108
+ setBgColor(color) {
109
+ this.mapService.setBgColor(color);
110
+ }
111
+ addLayer(layer) {
112
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
113
+ layer.setContainer(layerContainer, this.container);
114
+ this.sceneService.addLayer(layer);
115
+ const layerConfig = layer.getLayerConfig();
116
+ if (layerConfig) {
117
+ const {
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
+ }
130
+ } else {
131
+ console.warn("addLayer should run after scene loaded!");
132
+ }
133
+ }
134
+ addMask(mask, layerId) {
135
+ const parent = this.getLayer(layerId);
136
+ if (parent) {
137
+ const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
138
+ mask.setContainer(layerContainer, this.container);
139
+ parent.addMaskLayer(mask);
140
+ this.sceneService.addLayer(mask);
141
+ } else {
142
+ console.warn("parent layer not find!");
143
+ }
144
+ }
145
+ getPickedLayer() {
146
+ return this.layerService.pickedLayerId;
147
+ }
148
+ getLayers() {
149
+ return this.layerService.getLayers();
150
+ }
151
+ getLayer(id) {
152
+ return this.layerService.getLayer(id);
153
+ }
154
+ getLayerByName(name) {
155
+ return this.layerService.getLayerByName(name);
156
+ }
157
+ removeLayer(layer, parentLayer) {
158
+ this.layerService.remove(layer, parentLayer);
159
+ }
160
+ removeAllLayer() {
161
+ this.layerService.removeAllLayers();
162
+ }
163
+ render() {
164
+ this.sceneService.render();
165
+ }
166
+ setEnableRender(flag) {
167
+ this.layerService.setEnableRender(flag);
168
+ }
169
+ addIconFont(name, fontUnicode) {
170
+ this.fontService.addIconFont(name, fontUnicode);
171
+ }
172
+ addIconFonts(options) {
173
+ options.forEach(([name, fontUnicode]) => {
174
+ this.fontService.addIconFont(name, fontUnicode);
175
+ });
176
+ }
177
+ addFontFace(fontFamily, fontPath) {
178
+ this.sceneService.addFontFace(fontFamily, fontPath);
179
+ }
180
+ addImage(id, img) {
181
+ if (!import_l7_utils.isMini) {
182
+ this.iconService.addImage(id, img);
183
+ } else {
184
+ this.iconService.addImageMini(id, img, this.sceneService);
185
+ }
186
+ }
187
+ hasImage(id) {
188
+ return this.iconService.hasImage(id);
189
+ }
190
+ removeImage(id) {
191
+ this.iconService.removeImage(id);
192
+ }
193
+ addIconFontGlyphs(fontFamily, glyphs) {
194
+ this.fontService.addIconGlyphs(glyphs);
195
+ }
196
+ addControl(ctr) {
197
+ this.controlService.addControl(ctr, this.container);
198
+ }
199
+ removeControl(ctr) {
200
+ this.controlService.removeControl(ctr);
201
+ }
202
+ getControlByName(name) {
203
+ return this.controlService.getControlByName(name);
204
+ }
205
+ addMarker(marker) {
206
+ this.markerService.addMarker(marker);
207
+ }
208
+ addMarkerLayer(layer) {
209
+ this.markerService.addMarkerLayer(layer);
210
+ }
211
+ removeMarkerLayer(layer) {
212
+ this.markerService.removeMarkerLayer(layer);
213
+ }
214
+ removeAllMakers() {
215
+ this.markerService.removeAllMarkers();
216
+ }
217
+ addPopup(popup) {
218
+ this.popupService.addPopup(popup);
219
+ }
220
+ removePopup(popup) {
221
+ this.popupService.removePopup(popup);
222
+ }
223
+ on(type, handle) {
224
+ var _a;
225
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
226
+ (_a = this.boxSelect) == null ? void 0 : _a.on(type, handle);
227
+ } else if (import_l7_core.SceneEventList.includes(type)) {
228
+ this.sceneService.on(type, handle);
229
+ } else {
230
+ this.mapService.on(type, handle);
231
+ }
232
+ }
233
+ once(type, handle) {
234
+ var _a;
235
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
236
+ (_a = this.boxSelect) == null ? void 0 : _a.once(type, handle);
237
+ } else if (import_l7_core.SceneEventList.includes(type)) {
238
+ this.sceneService.once(type, handle);
239
+ } else {
240
+ this.mapService.once(type, handle);
241
+ }
242
+ }
243
+ off(type, handle) {
244
+ var _a;
245
+ if (import_boxSelect.BoxSelectEventList.includes(type)) {
246
+ (_a = this.boxSelect) == null ? void 0 : _a.off(type, handle);
247
+ } else if (import_l7_core.SceneEventList.includes(type)) {
248
+ this.sceneService.off(type, handle);
249
+ } else {
250
+ this.mapService.off(type, handle);
251
+ }
252
+ }
253
+ getZoom() {
254
+ return this.mapService.getZoom();
255
+ }
256
+ getCenter(options) {
257
+ return this.mapService.getCenter(options);
258
+ }
259
+ setCenter(center, options) {
260
+ return this.mapService.setCenter(center, options);
261
+ }
262
+ getPitch() {
263
+ return this.mapService.getPitch();
264
+ }
265
+ setPitch(pitch) {
266
+ return this.mapService.setPitch(pitch);
267
+ }
268
+ getRotation() {
269
+ return this.mapService.getRotation();
270
+ }
271
+ getBounds() {
272
+ return this.mapService.getBounds();
273
+ }
274
+ setRotation(rotation) {
275
+ this.mapService.setRotation(rotation);
276
+ }
277
+ zoomIn() {
278
+ this.mapService.zoomIn();
279
+ }
280
+ zoomOut() {
281
+ this.mapService.zoomOut();
282
+ }
283
+ panTo(p) {
284
+ this.mapService.panTo(p);
285
+ }
286
+ panBy(x, y) {
287
+ this.mapService.panBy(x, y);
288
+ }
289
+ getContainer() {
290
+ return this.mapService.getContainer();
291
+ }
292
+ setZoom(zoom) {
293
+ this.mapService.setZoom(zoom);
294
+ }
295
+ fitBounds(bound, options) {
296
+ const { fitBoundsOptions, animate } = this.sceneService.getSceneConfig();
297
+ this.mapService.fitBounds(bound, options || {
298
+ ...fitBoundsOptions,
299
+ animate
300
+ });
301
+ }
302
+ setZoomAndCenter(zoom, center) {
303
+ this.mapService.setZoomAndCenter(zoom, center);
304
+ }
305
+ setMapStyle(style) {
306
+ this.mapService.setMapStyle(style);
307
+ }
308
+ setMapStatus(options) {
309
+ this.mapService.setMapStatus(options);
310
+ }
311
+ pixelToLngLat(pixel) {
312
+ return this.mapService.pixelToLngLat(pixel);
313
+ }
314
+ lngLatToPixel(lnglat) {
315
+ return this.mapService.lngLatToPixel(lnglat);
316
+ }
317
+ containerToLngLat(pixel) {
318
+ return this.mapService.containerToLngLat(pixel);
319
+ }
320
+ lngLatToContainer(lnglat) {
321
+ return this.mapService.lngLatToContainer(lnglat);
322
+ }
323
+ destroy() {
324
+ this.sceneService.destroy();
325
+ }
326
+ registerPostProcessingPass(constructor, name) {
327
+ this.container.bind(import_l7_core.TYPES.IPostProcessingPass).to(constructor).whenTargetNamed(name);
328
+ }
329
+ enableShaderPick() {
330
+ this.layerService.enableShaderPick();
331
+ }
332
+ diasbleShaderPick() {
333
+ this.layerService.disableShaderPick();
334
+ }
335
+ enableBoxSelect(once = true) {
336
+ this.boxSelect.enable();
337
+ if (once) {
338
+ this.boxSelect.once("selectend", () => {
339
+ this.disableBoxSelect();
340
+ });
341
+ }
342
+ }
343
+ disableBoxSelect() {
344
+ this.boxSelect.disable();
345
+ }
346
+ getPointSizeRange() {
347
+ return this.sceneService.getPointSizeRange();
348
+ }
349
+ initComponent(id) {
350
+ this.controlService.init({
351
+ container: import_l7_utils.DOM.getContainer(id)
352
+ }, this.container);
353
+ this.markerService.init(this.container);
354
+ this.popupService.init(this.container);
355
+ }
356
+ initControl() {
357
+ const { logoVisible, logoPosition } = this.sceneService.getSceneConfig();
358
+ if (logoVisible) {
359
+ this.addControl(new import_l7_component.Logo({ position: logoPosition }));
360
+ }
361
+ }
362
+ };
363
+ // Annotate the CommonJS export names for ESM import in node:
364
+ 0 && (module.exports = {
365
+ Scene
366
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-scene",
3
- "version": "2.9.32-alpha.3",
3
+ "version": "2.9.32-alpha.4",
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.32-alpha.3",
27
- "@antv/l7-core": "2.9.32-alpha.3",
28
- "@antv/l7-layers": "2.9.32-alpha.3",
29
- "@antv/l7-maps": "2.9.32-alpha.3",
30
- "@antv/l7-renderer": "2.9.32-alpha.3",
31
- "@antv/l7-utils": "2.9.32-alpha.3",
26
+ "@antv/l7-component": "2.9.32-alpha.4",
27
+ "@antv/l7-core": "2.9.32-alpha.4",
28
+ "@antv/l7-layers": "2.9.32-alpha.4",
29
+ "@antv/l7-maps": "2.9.32-alpha.4",
30
+ "@antv/l7-renderer": "2.9.32-alpha.4",
31
+ "@antv/l7-utils": "2.9.32-alpha.4",
32
32
  "@babel/runtime": "^7.7.7",
33
33
  "@turf/turf": "^6.5.0",
34
34
  "eventemitter3": "^4.0.7",
@@ -37,9 +37,9 @@
37
37
  "reflect-metadata": "^0.1.13"
38
38
  },
39
39
  "devDependencies": {
40
- "@antv/l7-test-utils": "2.9.32-alpha.3"
40
+ "@antv/l7-test-utils": "2.9.32-alpha.4"
41
41
  },
42
- "gitHead": "933f97b7f72989a523c164677235546838b476bf",
42
+ "gitHead": "17a8a05d41a0007db94568d2902a8f539d6e3abc",
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  }