@antv/l7-scene 2.21.0 → 2.21.2

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 CHANGED
@@ -1,48 +1,65 @@
1
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
- import _createClass from "@babel/runtime/helpers/esm/createClass";
6
- import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import { Logo } from '@antv/l7-component';
8
- import { SceneEventList, createLayerContainer, createSceneContainer } from '@antv/l7-core';
9
- import { MaskLayer, TileLayer } from '@antv/l7-layers';
10
- import { DeviceRendererService, ReglRendererService } from '@antv/l7-renderer';
11
- import { DOM, SceneConifg } from '@antv/l7-utils';
12
- import BoxSelect, { BoxSelectEventList } from "./boxSelect";
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
+ };
13
40
 
14
- /**
15
- * 暴露 Scene API
16
- *
17
- * @example
18
- * import { Scene } from 'l7/scene';
19
- * import { PointLayer } from 'l7/layers';
20
- *
21
- * const scene = new Scene();
22
- * const pointLayer = new PointLayer();
23
- * scene.addLayer(pointLayer);
24
- *
25
- */
26
- var Scene = /*#__PURE__*/function () {
27
- function Scene(config) {
28
- _classCallCheck(this, Scene);
29
- var id = config.id,
30
- map = config.map,
31
- canvas = config.canvas,
32
- _config$renderer = config.renderer,
33
- renderer = _config$renderer === void 0 ? 'regl' : _config$renderer;
34
- // 创建场景容器
35
- var sceneContainer = createSceneContainer();
41
+ // src/index.ts
42
+ import { Logo } from "@antv/l7-component";
43
+ import {
44
+ SceneEventList,
45
+ createLayerContainer,
46
+ createSceneContainer
47
+ } from "@antv/l7-core";
48
+ import { MaskLayer, TileLayer } from "@antv/l7-layers";
49
+ import { DeviceRendererService, ReglRendererService } from "@antv/l7-renderer";
50
+ import { DOM, SceneConifg } from "@antv/l7-utils";
51
+ import BoxSelect, { BoxSelectEventList } from "./boxSelect";
52
+ var Scene = class {
53
+ constructor(config) {
54
+ const { id, map, canvas, renderer = "regl" } = config;
55
+ const sceneContainer = createSceneContainer();
36
56
  this.container = sceneContainer;
37
- // 绑定地图服务
38
57
  map.setContainer(sceneContainer, id, canvas);
39
- if (renderer === 'regl') {
58
+ if (renderer === "regl") {
40
59
  sceneContainer.rendererService = new ReglRendererService();
41
60
  } else {
42
61
  sceneContainer.rendererService = new DeviceRendererService();
43
62
  }
44
-
45
- // 依赖注入
46
63
  this.sceneService = sceneContainer.sceneService;
47
64
  this.mapService = sceneContainer.mapService;
48
65
  this.iconService = sceneContainer.iconService;
@@ -56,668 +73,401 @@ var Scene = /*#__PURE__*/function () {
56
73
  this.popupService = sceneContainer.popupService;
57
74
  this.boxSelect = new BoxSelect(this, {});
58
75
  this.initComponent(id);
59
-
60
- // 初始化 scene
61
76
  this.sceneService.init(config);
62
- // TODO: 初始化组件
63
-
64
77
  this.initControl();
65
78
  }
66
- _createClass(Scene, [{
67
- key: "map",
68
- get: function get() {
69
- return this.mapService.map;
70
- }
71
- }, {
72
- key: "loaded",
73
- get: function get() {
74
- return this.sceneService.loaded;
75
- }
76
- }, {
77
- key: "getServiceContainer",
78
- value: function getServiceContainer() {
79
- return this.container;
80
- }
81
- }, {
82
- key: "getSize",
83
- value: function getSize() {
84
- return this.mapService.getSize();
85
- }
86
- }, {
87
- key: "getMinZoom",
88
- value: function getMinZoom() {
89
- return this.mapService.getMinZoom();
90
- }
91
- }, {
92
- key: "getMaxZoom",
93
- value: function getMaxZoom() {
94
- return this.mapService.getMaxZoom();
95
- }
96
- }, {
97
- key: "getType",
98
- value: function getType() {
99
- return this.mapService.getType();
100
- }
101
- }, {
102
- key: "getMapContainer",
103
- value: function getMapContainer() {
104
- return this.mapService.getMapContainer();
105
- }
106
- }, {
107
- key: "getMapCanvasContainer",
108
- value: function getMapCanvasContainer() {
109
- return this.mapService.getMapCanvasContainer();
110
- }
111
- }, {
112
- key: "getMapService",
113
- value: function getMapService() {
114
- return this.mapService;
115
- }
116
-
117
- /**
118
- * 对外暴露 debugService
119
- * @returns
120
- */
121
- }, {
122
- key: "getDebugService",
123
- value: function getDebugService() {
124
- return this.debugService;
125
- }
126
- }, {
127
- key: "exportPng",
128
- value: function () {
129
- var _exportPng = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(type) {
130
- return _regeneratorRuntime.wrap(function _callee$(_context) {
131
- while (1) switch (_context.prev = _context.next) {
132
- case 0:
133
- return _context.abrupt("return", this.sceneService.exportPng(type));
134
- case 1:
135
- case "end":
136
- return _context.stop();
137
- }
138
- }, _callee, this);
139
- }));
140
- function exportPng(_x) {
141
- return _exportPng.apply(this, arguments);
142
- }
143
- return exportPng;
144
- }()
145
- }, {
146
- key: "exportMap",
147
- value: function () {
148
- var _exportMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(type) {
149
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
150
- while (1) switch (_context2.prev = _context2.next) {
151
- case 0:
152
- return _context2.abrupt("return", this.sceneService.exportPng(type));
153
- case 1:
154
- case "end":
155
- return _context2.stop();
156
- }
157
- }, _callee2, this);
158
- }));
159
- function exportMap(_x2) {
160
- return _exportMap.apply(this, arguments);
161
- }
162
- return exportMap;
163
- }()
164
- }, {
165
- key: "registerRenderService",
166
- value: function registerRenderService(render) {
167
- var _this = this;
168
- if (this.sceneService.loaded) {
169
- var renderSerivce = new render(this);
79
+ get map() {
80
+ return this.mapService.map;
81
+ }
82
+ get loaded() {
83
+ return this.sceneService.loaded;
84
+ }
85
+ getServiceContainer() {
86
+ return this.container;
87
+ }
88
+ getSize() {
89
+ return this.mapService.getSize();
90
+ }
91
+ getMinZoom() {
92
+ return this.mapService.getMinZoom();
93
+ }
94
+ getMaxZoom() {
95
+ return this.mapService.getMaxZoom();
96
+ }
97
+ getType() {
98
+ return this.mapService.getType();
99
+ }
100
+ getMapContainer() {
101
+ return this.mapService.getMapContainer();
102
+ }
103
+ getMapCanvasContainer() {
104
+ return this.mapService.getMapCanvasContainer();
105
+ }
106
+ getMapService() {
107
+ return this.mapService;
108
+ }
109
+ /**
110
+ * 对外暴露 debugService
111
+ * @returns
112
+ */
113
+ getDebugService() {
114
+ return this.debugService;
115
+ }
116
+ exportPng(type) {
117
+ return __async(this, null, function* () {
118
+ return this.sceneService.exportPng(type);
119
+ });
120
+ }
121
+ exportMap(type) {
122
+ return __async(this, null, function* () {
123
+ return this.sceneService.exportPng(type);
124
+ });
125
+ }
126
+ registerRenderService(render) {
127
+ if (this.sceneService.loaded) {
128
+ const renderSerivce = new render(this);
129
+ renderSerivce.init();
130
+ } else {
131
+ this.on("loaded", () => {
132
+ const renderSerivce = new render(this);
170
133
  renderSerivce.init();
171
- } else {
172
- this.on('loaded', function () {
173
- var renderSerivce = new render(_this);
174
- renderSerivce.init();
175
- });
176
- }
177
- }
178
- }, {
179
- key: "setBgColor",
180
- value: function setBgColor(color) {
181
- this.mapService.setBgColor(color);
134
+ });
182
135
  }
183
- }, {
184
- key: "addLayer",
185
- value: function addLayer(layer) {
186
- var _this2 = this;
187
- if (this.loaded) {
136
+ }
137
+ setBgColor(color) {
138
+ this.mapService.setBgColor(color);
139
+ }
140
+ addLayer(layer) {
141
+ if (this.loaded) {
142
+ this.preAddLayer(layer);
143
+ } else {
144
+ this.once("loaded", () => {
188
145
  this.preAddLayer(layer);
189
- } else {
190
- console.log('layer not loaded');
191
- this.once('loaded', function () {
192
- console.log('layer loaded');
193
- _this2.preAddLayer(layer);
194
- });
195
- }
146
+ });
196
147
  }
197
-
198
- // layer 管理
199
- }, {
200
- key: "preAddLayer",
201
- value: function preAddLayer(layer) {
202
- var _this3 = this;
203
- // 为当前图层创建一个容器
204
- // TODO: 初始化的时候设置 容器
205
- var layerContainer = createLayerContainer(this.container);
206
- layer.setContainer(layerContainer);
207
- this.sceneService.addLayer(layer);
208
-
209
- // mask 在 scene loaded 之后执行
210
- if (layer.inited) {
148
+ }
149
+ // layer 管理
150
+ preAddLayer(layer) {
151
+ const layerContainer = createLayerContainer(this.container);
152
+ layer.setContainer(layerContainer);
153
+ this.sceneService.addLayer(layer);
154
+ if (layer.inited) {
155
+ this.initTileLayer(layer);
156
+ const maskInstance = this.initMask(layer);
157
+ this.addMask(maskInstance, layer.id);
158
+ } else {
159
+ layer.on("inited", () => {
211
160
  this.initTileLayer(layer);
212
- var maskInstance = this.initMask(layer);
161
+ const maskInstance = this.initMask(layer);
213
162
  this.addMask(maskInstance, layer.id);
214
- } else {
215
- layer.on('inited', function () {
216
- _this3.initTileLayer(layer);
217
- var maskInstance = _this3.initMask(layer); // 初始化 mask
218
- _this3.addMask(maskInstance, layer.id);
219
- });
220
- }
221
- }
222
- // 兼容历史接口
223
- }, {
224
- key: "initMask",
225
- value: function initMask(layer) {
226
- var _layer$getLayerConfig = layer.getLayerConfig(),
227
- mask = _layer$getLayerConfig.mask,
228
- maskfence = _layer$getLayerConfig.maskfence,
229
- _layer$getLayerConfig2 = _layer$getLayerConfig.maskColor,
230
- maskColor = _layer$getLayerConfig2 === void 0 ? '#000' : _layer$getLayerConfig2,
231
- _layer$getLayerConfig3 = _layer$getLayerConfig.maskOpacity,
232
- maskOpacity = _layer$getLayerConfig3 === void 0 ? 0 : _layer$getLayerConfig3;
233
- if (!mask || !maskfence) {
234
- return undefined;
235
- }
236
- var maskInstance = new MaskLayer().source(maskfence).shape('fill').style({
237
- color: maskColor,
238
- opacity: maskOpacity
239
163
  });
240
- return maskInstance;
241
164
  }
242
- }, {
243
- key: "addMask",
244
- value: function addMask(mask, layerId) {
245
- if (!mask) {
246
- return;
247
- }
248
- var parent = this.getLayer(layerId);
249
- if (parent) {
250
- var layerContainer = createLayerContainer(this.container);
251
- mask.setContainer(layerContainer);
252
- parent.addMaskLayer(mask);
253
- this.sceneService.addMask(mask);
254
- } else {
255
- console.warn('parent layer not find!');
256
- }
257
- }
258
- }, {
259
- key: "getPickedLayer",
260
- value: function getPickedLayer() {
261
- return this.layerService.pickedLayerId;
262
- }
263
- }, {
264
- key: "getLayers",
265
- value: function getLayers() {
266
- return this.layerService.getLayers();
267
- }
268
- }, {
269
- key: "getLayer",
270
- value: function getLayer(id) {
271
- return this.layerService.getLayer(id);
272
- }
273
- }, {
274
- key: "getLayerByName",
275
- value: function getLayerByName(name) {
276
- return this.layerService.getLayerByName(name);
277
- }
278
- }, {
279
- key: "removeLayer",
280
- value: function () {
281
- var _removeLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(layer, parentLayer) {
282
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
283
- while (1) switch (_context3.prev = _context3.next) {
284
- case 0:
285
- _context3.next = 2;
286
- return this.layerService.remove(layer, parentLayer);
287
- case 2:
288
- case "end":
289
- return _context3.stop();
290
- }
291
- }, _callee3, this);
292
- }));
293
- function removeLayer(_x3, _x4) {
294
- return _removeLayer.apply(this, arguments);
295
- }
296
- return removeLayer;
297
- }()
298
- }, {
299
- key: "removeAllLayer",
300
- value: function () {
301
- var _removeAllLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
302
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
303
- while (1) switch (_context4.prev = _context4.next) {
304
- case 0:
305
- _context4.next = 2;
306
- return this.layerService.removeAllLayers();
307
- case 2:
308
- case "end":
309
- return _context4.stop();
310
- }
311
- }, _callee4, this);
312
- }));
313
- function removeAllLayer() {
314
- return _removeAllLayer.apply(this, arguments);
315
- }
316
- return removeAllLayer;
317
- }()
318
- }, {
319
- key: "render",
320
- value: function render() {
321
- this.sceneService.render();
322
- }
323
- }, {
324
- key: "setEnableRender",
325
- value: function setEnableRender(flag) {
326
- this.layerService.setEnableRender(flag);
165
+ }
166
+ // 兼容历史接口
167
+ initMask(layer) {
168
+ const {
169
+ mask,
170
+ maskfence,
171
+ maskColor = "#000",
172
+ maskOpacity = 0
173
+ } = layer.getLayerConfig();
174
+ if (!mask || !maskfence) {
175
+ return void 0;
176
+ }
177
+ const maskInstance = new MaskLayer().source(maskfence).shape("fill").style({
178
+ color: maskColor,
179
+ opacity: maskOpacity
180
+ });
181
+ return maskInstance;
182
+ }
183
+ addMask(mask, layerId) {
184
+ if (!mask) {
185
+ return;
186
+ }
187
+ const parent = this.getLayer(layerId);
188
+ if (parent) {
189
+ const layerContainer = createLayerContainer(this.container);
190
+ mask.setContainer(layerContainer);
191
+ parent.addMaskLayer(mask);
192
+ this.sceneService.addMask(mask);
193
+ } else {
194
+ console.warn("parent layer not find!");
327
195
  }
328
-
329
- // asset method
330
- /**
331
- * 为 layer/point/text 支持 iconfont 模式支持
332
- * @param fontUnicode
333
- * @param name
334
- */
335
- }, {
336
- key: "addIconFont",
337
- value: function addIconFont(name, fontUnicode) {
196
+ }
197
+ getPickedLayer() {
198
+ return this.layerService.pickedLayerId;
199
+ }
200
+ getLayers() {
201
+ return this.layerService.getLayers();
202
+ }
203
+ getLayer(id) {
204
+ return this.layerService.getLayer(id);
205
+ }
206
+ getLayerByName(name) {
207
+ return this.layerService.getLayerByName(name);
208
+ }
209
+ removeLayer(layer, parentLayer) {
210
+ return __async(this, null, function* () {
211
+ yield this.layerService.remove(layer, parentLayer);
212
+ });
213
+ }
214
+ removeAllLayer() {
215
+ return __async(this, null, function* () {
216
+ yield this.layerService.removeAllLayers();
217
+ });
218
+ }
219
+ render() {
220
+ this.sceneService.render();
221
+ }
222
+ setEnableRender(flag) {
223
+ this.layerService.setEnableRender(flag);
224
+ }
225
+ // asset method
226
+ /**
227
+ * 为 layer/point/text 支持 iconfont 模式支持
228
+ * @param fontUnicode
229
+ * @param name
230
+ */
231
+ addIconFont(name, fontUnicode) {
232
+ this.fontService.addIconFont(name, fontUnicode);
233
+ }
234
+ addIconFonts(options) {
235
+ options.forEach(([name, fontUnicode]) => {
338
236
  this.fontService.addIconFont(name, fontUnicode);
237
+ });
238
+ }
239
+ /**
240
+ * 用户自定义添加第三方字体
241
+ * @param fontFamily
242
+ * @param fontPath
243
+ */
244
+ addFontFace(fontFamily, fontPath) {
245
+ this.fontService.once("fontloaded", (e) => {
246
+ this.emit("fontloaded", e);
247
+ });
248
+ this.fontService.addFontFace(fontFamily, fontPath);
249
+ }
250
+ addImage(id, img) {
251
+ return __async(this, null, function* () {
252
+ yield this.iconService.addImage(id, img);
253
+ });
254
+ }
255
+ hasImage(id) {
256
+ return this.iconService.hasImage(id);
257
+ }
258
+ removeImage(id) {
259
+ this.iconService.removeImage(id);
260
+ }
261
+ addIconFontGlyphs(fontFamily, glyphs) {
262
+ this.fontService.addIconGlyphs(glyphs);
263
+ }
264
+ // map control method
265
+ addControl(ctr) {
266
+ this.controlService.addControl(ctr, this.container);
267
+ }
268
+ removeControl(ctr) {
269
+ this.controlService.removeControl(ctr);
270
+ }
271
+ getControlByName(name) {
272
+ return this.controlService.getControlByName(name);
273
+ }
274
+ // marker
275
+ addMarker(marker) {
276
+ this.markerService.addMarker(marker);
277
+ }
278
+ addMarkerLayer(layer) {
279
+ this.markerService.addMarkerLayer(layer);
280
+ }
281
+ removeMarkerLayer(layer) {
282
+ this.markerService.removeMarkerLayer(layer);
283
+ }
284
+ removeAllMarkers() {
285
+ this.markerService.removeAllMarkers();
286
+ }
287
+ removeAllMakers() {
288
+ console.warn("removeAllMakers 已废弃,请使用 removeAllMarkers");
289
+ this.markerService.removeAllMarkers();
290
+ }
291
+ addPopup(popup) {
292
+ this.popupService.addPopup(popup);
293
+ }
294
+ removePopup(popup) {
295
+ this.popupService.removePopup(popup);
296
+ }
297
+ on(type, handle) {
298
+ var _a;
299
+ if (BoxSelectEventList.includes(type)) {
300
+ (_a = this.boxSelect) == null ? void 0 : _a.on(type, handle);
301
+ } else if (SceneEventList.includes(type)) {
302
+ this.sceneService.on(type, handle);
303
+ } else {
304
+ this.mapService.on(type, handle);
339
305
  }
340
- }, {
341
- key: "addIconFonts",
342
- value: function addIconFonts(options) {
343
- var _this4 = this;
344
- options.forEach(function (_ref) {
345
- var _ref2 = _slicedToArray(_ref, 2),
346
- name = _ref2[0],
347
- fontUnicode = _ref2[1];
348
- _this4.fontService.addIconFont(name, fontUnicode);
349
- });
350
- }
351
- /**
352
- * 用户自定义添加第三方字体
353
- * @param fontFamily
354
- * @param fontPath
355
- */
356
- }, {
357
- key: "addFontFace",
358
- value: function addFontFace(fontFamily, fontPath) {
359
- var _this5 = this;
360
- this.fontService.once('fontloaded', function (e) {
361
- _this5.emit('fontloaded', e);
362
- });
363
- this.fontService.addFontFace(fontFamily, fontPath);
364
- }
365
- }, {
366
- key: "addImage",
367
- value: function () {
368
- var _addImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, img) {
369
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
370
- while (1) switch (_context5.prev = _context5.next) {
371
- case 0:
372
- _context5.next = 2;
373
- return this.iconService.addImage(id, img);
374
- case 2:
375
- case "end":
376
- return _context5.stop();
377
- }
378
- }, _callee5, this);
379
- }));
380
- function addImage(_x5, _x6) {
381
- return _addImage.apply(this, arguments);
382
- }
383
- return addImage;
384
- }()
385
- }, {
386
- key: "hasImage",
387
- value: function hasImage(id) {
388
- return this.iconService.hasImage(id);
389
- }
390
- }, {
391
- key: "removeImage",
392
- value: function removeImage(id) {
393
- this.iconService.removeImage(id);
394
- }
395
- }, {
396
- key: "addIconFontGlyphs",
397
- value: function addIconFontGlyphs(fontFamily, glyphs) {
398
- this.fontService.addIconGlyphs(glyphs);
399
- }
400
-
401
- // map control method
402
- }, {
403
- key: "addControl",
404
- value: function addControl(ctr) {
405
- this.controlService.addControl(ctr, this.container);
406
- }
407
- }, {
408
- key: "removeControl",
409
- value: function removeControl(ctr) {
410
- this.controlService.removeControl(ctr);
411
- }
412
- }, {
413
- key: "getControlByName",
414
- value: function getControlByName(name) {
415
- return this.controlService.getControlByName(name);
416
- }
417
-
418
- // marker
419
- }, {
420
- key: "addMarker",
421
- value: function addMarker(marker) {
422
- this.markerService.addMarker(marker);
423
- }
424
- }, {
425
- key: "addMarkerLayer",
426
- value: function addMarkerLayer(layer) {
427
- this.markerService.addMarkerLayer(layer);
428
- }
429
- }, {
430
- key: "removeMarkerLayer",
431
- value: function removeMarkerLayer(layer) {
432
- this.markerService.removeMarkerLayer(layer);
433
- }
434
- }, {
435
- key: "removeAllMarkers",
436
- value: function removeAllMarkers() {
437
- this.markerService.removeAllMarkers();
438
- }
439
- }, {
440
- key: "removeAllMakers",
441
- value: function removeAllMakers() {
442
- console.warn('removeAllMakers 已废弃,请使用 removeAllMarkers');
443
- this.markerService.removeAllMarkers();
444
- }
445
- }, {
446
- key: "addPopup",
447
- value: function addPopup(popup) {
448
- this.popupService.addPopup(popup);
449
- }
450
- }, {
451
- key: "removePopup",
452
- value: function removePopup(popup) {
453
- this.popupService.removePopup(popup);
454
- }
455
- }, {
456
- key: "on",
457
- value: function on(type, handle) {
458
- if (BoxSelectEventList.includes(type)) {
459
- var _this$boxSelect;
460
- (_this$boxSelect = this.boxSelect) === null || _this$boxSelect === void 0 || _this$boxSelect.on(type, handle);
461
- } else if (SceneEventList.includes(type)) {
462
- this.sceneService.on(type, handle);
463
- } else {
464
- this.mapService.on(type, handle);
465
- }
466
- }
467
- }, {
468
- key: "once",
469
- value: function once(type, handle) {
470
- if (BoxSelectEventList.includes(type)) {
471
- var _this$boxSelect2;
472
- (_this$boxSelect2 = this.boxSelect) === null || _this$boxSelect2 === void 0 || _this$boxSelect2.once(type, handle);
473
- } else if (SceneEventList.includes(type)) {
474
- this.sceneService.once(type, handle);
475
- } else {
476
- this.mapService.once(type, handle);
477
- }
478
- }
479
- }, {
480
- key: "emit",
481
- value: function emit(type, handle) {
482
- SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.emit(type, handle);
483
- }
484
- }, {
485
- key: "off",
486
- value: function off(type, handle) {
487
- if (BoxSelectEventList.includes(type)) {
488
- var _this$boxSelect3;
489
- (_this$boxSelect3 = this.boxSelect) === null || _this$boxSelect3 === void 0 || _this$boxSelect3.off(type, handle);
490
- } else if (SceneEventList.includes(type)) {
491
- this.sceneService.off(type, handle);
492
- } else {
493
- this.mapService.off(type, handle);
494
- }
495
- }
496
-
497
- // implements IMapController
498
- }, {
499
- key: "getZoom",
500
- value: function getZoom() {
501
- return this.mapService.getZoom();
502
- }
503
- }, {
504
- key: "getCenter",
505
- value: function getCenter(options) {
506
- return this.mapService.getCenter(options);
507
- }
508
- }, {
509
- key: "setCenter",
510
- value: function setCenter(center, options) {
511
- return this.mapService.setCenter(center, options);
512
- }
513
- }, {
514
- key: "getPitch",
515
- value: function getPitch() {
516
- return this.mapService.getPitch();
517
- }
518
- }, {
519
- key: "setPitch",
520
- value: function setPitch(pitch) {
521
- return this.mapService.setPitch(pitch);
522
- }
523
- }, {
524
- key: "getRotation",
525
- value: function getRotation() {
526
- return this.mapService.getRotation();
527
- }
528
- }, {
529
- key: "getBounds",
530
- value: function getBounds() {
531
- return this.mapService.getBounds();
532
- }
533
- }, {
534
- key: "setRotation",
535
- value: function setRotation(rotation) {
536
- this.mapService.setRotation(rotation);
537
- }
538
- }, {
539
- key: "zoomIn",
540
- value: function zoomIn() {
541
- this.mapService.zoomIn();
542
- }
543
- }, {
544
- key: "zoomOut",
545
- value: function zoomOut() {
546
- this.mapService.zoomOut();
547
- }
548
- }, {
549
- key: "panTo",
550
- value: function panTo(p) {
551
- this.mapService.panTo(p);
552
- }
553
- }, {
554
- key: "panBy",
555
- value: function panBy(x, y) {
556
- this.mapService.panBy(x, y);
557
- }
558
- }, {
559
- key: "getContainer",
560
- value: function getContainer() {
561
- return this.mapService.getContainer();
306
+ }
307
+ once(type, handle) {
308
+ var _a;
309
+ if (BoxSelectEventList.includes(type)) {
310
+ (_a = this.boxSelect) == null ? void 0 : _a.once(type, handle);
311
+ } else if (SceneEventList.includes(type)) {
312
+ this.sceneService.once(type, handle);
313
+ } else {
314
+ this.mapService.once(type, handle);
562
315
  }
563
- }, {
564
- key: "setZoom",
565
- value: function setZoom(zoom) {
566
- this.mapService.setZoom(zoom);
316
+ }
317
+ emit(type, handle) {
318
+ SceneEventList.indexOf(type) === -1 ? this.mapService.on(type, handle) : this.sceneService.emit(type, handle);
319
+ }
320
+ off(type, handle) {
321
+ var _a;
322
+ if (BoxSelectEventList.includes(type)) {
323
+ (_a = this.boxSelect) == null ? void 0 : _a.off(type, handle);
324
+ } else if (SceneEventList.includes(type)) {
325
+ this.sceneService.off(type, handle);
326
+ } else {
327
+ this.mapService.off(type, handle);
567
328
  }
568
- }, {
569
- key: "fitBounds",
570
- value: function fitBounds(bound, options) {
571
- var _this$sceneService$ge = this.sceneService.getSceneConfig(),
572
- fitBoundsOptions = _this$sceneService$ge.fitBoundsOptions,
573
- animate = _this$sceneService$ge.animate;
574
- this.mapService.fitBounds(bound,
329
+ }
330
+ // implements IMapController
331
+ getZoom() {
332
+ return this.mapService.getZoom();
333
+ }
334
+ getCenter(options) {
335
+ return this.mapService.getCenter(options);
336
+ }
337
+ setCenter(center, options) {
338
+ return this.mapService.setCenter(center, options);
339
+ }
340
+ getPitch() {
341
+ return this.mapService.getPitch();
342
+ }
343
+ setPitch(pitch) {
344
+ return this.mapService.setPitch(pitch);
345
+ }
346
+ getRotation() {
347
+ return this.mapService.getRotation();
348
+ }
349
+ getBounds() {
350
+ return this.mapService.getBounds();
351
+ }
352
+ setRotation(rotation) {
353
+ this.mapService.setRotation(rotation);
354
+ }
355
+ zoomIn() {
356
+ this.mapService.zoomIn();
357
+ }
358
+ zoomOut() {
359
+ this.mapService.zoomOut();
360
+ }
361
+ panTo(p) {
362
+ this.mapService.panTo(p);
363
+ }
364
+ panBy(x, y) {
365
+ this.mapService.panBy(x, y);
366
+ }
367
+ getContainer() {
368
+ return this.mapService.getContainer();
369
+ }
370
+ setZoom(zoom) {
371
+ this.mapService.setZoom(zoom);
372
+ }
373
+ fitBounds(bound, options) {
374
+ const { fitBoundsOptions, animate } = this.sceneService.getSceneConfig();
375
+ this.mapService.fitBounds(
376
+ bound,
575
377
  // 选项优先级:用户传入,覆盖animate直接配置,覆盖Scene配置项传入
576
- options || _objectSpread(_objectSpread({}, fitBoundsOptions), {}, {
577
- animate: animate
578
- }));
579
- }
580
- }, {
581
- key: "setZoomAndCenter",
582
- value: function setZoomAndCenter(zoom, center) {
583
- this.mapService.setZoomAndCenter(zoom, center);
584
- }
585
- }, {
586
- key: "setMapStyle",
587
- value: function setMapStyle(style) {
588
- this.mapService.setMapStyle(style);
589
- }
590
- }, {
591
- key: "setMapStatus",
592
- value: function setMapStatus(options) {
593
- this.mapService.setMapStatus(options);
594
- }
595
-
596
- // conversion Method
597
- }, {
598
- key: "pixelToLngLat",
599
- value: function pixelToLngLat(pixel) {
600
- return this.mapService.pixelToLngLat(pixel);
601
- }
602
- }, {
603
- key: "lngLatToPixel",
604
- value: function lngLatToPixel(lnglat) {
605
- return this.mapService.lngLatToPixel(lnglat);
606
- }
607
- }, {
608
- key: "containerToLngLat",
609
- value: function containerToLngLat(pixel) {
610
- return this.mapService.containerToLngLat(pixel);
611
- }
612
- }, {
613
- key: "lngLatToContainer",
614
- value: function lngLatToContainer(lnglat) {
615
- return this.mapService.lngLatToContainer(lnglat);
616
- }
617
- }, {
618
- key: "destroy",
619
- value: function destroy() {
620
- this.sceneService.destroy();
621
- // TODO: 清理其他 Service 例如 IconService
622
- }
623
- }, {
624
- key: "registerPostProcessingPass",
625
- value: function registerPostProcessingPass(constructor) {
626
- this.container.postProcessingPass.name = new constructor();
627
- }
628
-
629
- // 控制 shader pick 计算
630
- }, {
631
- key: "enableShaderPick",
632
- value: function enableShaderPick() {
633
- this.layerService.enableShaderPick();
634
- }
635
- }, {
636
- key: "diasbleShaderPick",
637
- value: function diasbleShaderPick() {
638
- this.layerService.disableShaderPick();
639
- }
640
- }, {
641
- key: "enableBoxSelect",
642
- value: function enableBoxSelect() {
643
- var _this6 = this;
644
- var once = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
645
- this.boxSelect.enable();
646
- if (once) {
647
- this.boxSelect.once('selectend', function () {
648
- _this6.disableBoxSelect();
649
- });
650
- }
651
- }
652
- }, {
653
- key: "disableBoxSelect",
654
- value: function disableBoxSelect() {
655
- this.boxSelect.disable();
656
- }
657
-
658
- // 数据协议
659
- }, {
660
- key: "getProtocol",
661
- value: function getProtocol(protocol) {
662
- return SceneConifg.REGISTERED_PROTOCOLS[protocol];
663
- }
664
- }, {
665
- key: "startAnimate",
666
- value: function startAnimate() {
667
- this.layerService.startAnimate();
668
- }
669
- }, {
670
- key: "stopAnimate",
671
- value: function stopAnimate() {
672
- this.layerService.stopAnimate();
673
- }
674
-
675
- // get current point size info
676
- }, {
677
- key: "getPointSizeRange",
678
- value: function getPointSizeRange() {
679
- return this.sceneService.getPointSizeRange();
378
+ options || __spreadProps(__spreadValues({}, fitBoundsOptions), {
379
+ animate
380
+ })
381
+ );
382
+ }
383
+ setZoomAndCenter(zoom, center) {
384
+ this.mapService.setZoomAndCenter(zoom, center);
385
+ }
386
+ setMapStyle(style) {
387
+ this.mapService.setMapStyle(style);
388
+ }
389
+ setMapStatus(options) {
390
+ this.mapService.setMapStatus(options);
391
+ }
392
+ // conversion Method
393
+ pixelToLngLat(pixel) {
394
+ return this.mapService.pixelToLngLat(pixel);
395
+ }
396
+ lngLatToPixel(lnglat) {
397
+ return this.mapService.lngLatToPixel(lnglat);
398
+ }
399
+ containerToLngLat(pixel) {
400
+ return this.mapService.containerToLngLat(pixel);
401
+ }
402
+ lngLatToContainer(lnglat) {
403
+ return this.mapService.lngLatToContainer(lnglat);
404
+ }
405
+ destroy() {
406
+ this.sceneService.destroy();
407
+ }
408
+ registerPostProcessingPass(constructor) {
409
+ this.container.postProcessingPass.name = new constructor();
410
+ }
411
+ // 控制 shader pick 计算
412
+ enableShaderPick() {
413
+ this.layerService.enableShaderPick();
414
+ }
415
+ diasbleShaderPick() {
416
+ this.layerService.disableShaderPick();
417
+ }
418
+ enableBoxSelect(once = true) {
419
+ this.boxSelect.enable();
420
+ if (once) {
421
+ this.boxSelect.once("selectend", () => {
422
+ this.disableBoxSelect();
423
+ });
680
424
  }
681
- }, {
682
- key: "initComponent",
683
- value: function initComponent(id) {
684
- this.controlService.init({
425
+ }
426
+ disableBoxSelect() {
427
+ this.boxSelect.disable();
428
+ }
429
+ // 数据协议
430
+ static addProtocol(protocol, handler) {
431
+ SceneConifg.REGISTERED_PROTOCOLS[protocol] = handler;
432
+ }
433
+ static removeProtocol(protocol) {
434
+ delete SceneConifg.REGISTERED_PROTOCOLS[protocol];
435
+ }
436
+ getProtocol(protocol) {
437
+ return SceneConifg.REGISTERED_PROTOCOLS[protocol];
438
+ }
439
+ startAnimate() {
440
+ this.layerService.startAnimate();
441
+ }
442
+ stopAnimate() {
443
+ this.layerService.stopAnimate();
444
+ }
445
+ // get current point size info
446
+ getPointSizeRange() {
447
+ return this.sceneService.getPointSizeRange();
448
+ }
449
+ initComponent(id) {
450
+ this.controlService.init(
451
+ {
685
452
  container: DOM.getContainer(id)
686
- }, this.container);
687
- this.markerService.init(this.container);
688
- this.popupService.init(this.container);
689
- }
690
- }, {
691
- key: "initControl",
692
- value: function initControl() {
693
- var _this$sceneService$ge2 = this.sceneService.getSceneConfig(),
694
- logoVisible = _this$sceneService$ge2.logoVisible,
695
- logoPosition = _this$sceneService$ge2.logoPosition;
696
- if (logoVisible) {
697
- this.addControl(new Logo({
698
- position: logoPosition
699
- }));
700
- }
701
- }
702
- }, {
703
- key: "initTileLayer",
704
- value: function initTileLayer(layer) {
705
- if (layer.getSource().isTile) {
706
- layer.tileLayer = new TileLayer(layer);
707
- // Todo 支持瓦片更新
708
- }
709
- }
710
- }], [{
711
- key: "addProtocol",
712
- value: function addProtocol(protocol, handler) {
713
- SceneConifg.REGISTERED_PROTOCOLS[protocol] = handler;
453
+ },
454
+ this.container
455
+ );
456
+ this.markerService.init(this.container);
457
+ this.popupService.init(this.container);
458
+ }
459
+ initControl() {
460
+ const { logoVisible, logoPosition } = this.sceneService.getSceneConfig();
461
+ if (logoVisible) {
462
+ this.addControl(new Logo({ position: logoPosition }));
714
463
  }
715
- }, {
716
- key: "removeProtocol",
717
- value: function removeProtocol(protocol) {
718
- delete SceneConifg.REGISTERED_PROTOCOLS[protocol];
464
+ }
465
+ initTileLayer(layer) {
466
+ if (layer.getSource().isTile) {
467
+ layer.tileLayer = new TileLayer(layer);
719
468
  }
720
- }]);
721
- return Scene;
722
- }();
723
- export { Scene };
469
+ }
470
+ };
471
+ export {
472
+ Scene
473
+ };