@antv/l7-scene 2.15.2 → 2.15.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.
- package/es/boxSelect.js +8 -36
- package/es/index.js +90 -129
- package/lib/boxSelect.js +11 -2
- package/lib/index.js +56 -12
- package/package.json +9 -9
package/es/boxSelect.js
CHANGED
|
@@ -5,61 +5,41 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
7
7
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
8
|
-
|
|
9
8
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
10
|
-
|
|
11
9
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
|
|
13
10
|
import { DOM, getBBoxFromPoints } from '@antv/l7-utils';
|
|
14
11
|
import { EventEmitter } from 'eventemitter3';
|
|
15
12
|
export var BoxSelectEventList = ['selectstart', 'selecting', 'selectend'];
|
|
16
|
-
|
|
17
13
|
// TODO: 将 BoxSelect 模块放在哪里比较合适
|
|
18
14
|
var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
19
15
|
_inherits(BoxSelect, _EventEmitter);
|
|
20
|
-
|
|
21
16
|
var _super = _createSuper(BoxSelect);
|
|
22
|
-
|
|
23
17
|
function BoxSelect(scene) {
|
|
24
18
|
var _this;
|
|
25
|
-
|
|
26
19
|
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
27
|
-
|
|
28
20
|
_classCallCheck(this, BoxSelect);
|
|
29
|
-
|
|
30
21
|
_this = _super.call(this);
|
|
31
|
-
|
|
32
22
|
_defineProperty(_assertThisInitialized(_this), "isEnable", false);
|
|
33
|
-
|
|
34
23
|
_defineProperty(_assertThisInitialized(_this), "onDragStart", function (e) {
|
|
35
24
|
_this.box.style.display = 'block';
|
|
36
25
|
_this.startEvent = _this.endEvent = e;
|
|
37
|
-
|
|
38
26
|
_this.syncBoxBound();
|
|
39
|
-
|
|
40
27
|
_this.emit('selectstart', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
41
28
|
});
|
|
42
|
-
|
|
43
29
|
_defineProperty(_assertThisInitialized(_this), "onDragging", function (e) {
|
|
44
30
|
_this.endEvent = e;
|
|
45
|
-
|
|
46
31
|
_this.syncBoxBound();
|
|
47
|
-
|
|
48
32
|
_this.emit('selecting', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
49
33
|
});
|
|
50
|
-
|
|
51
34
|
_defineProperty(_assertThisInitialized(_this), "onDragEnd", function (e) {
|
|
52
35
|
_this.endEvent = e;
|
|
53
36
|
_this.box.style.display = 'none';
|
|
54
|
-
|
|
55
37
|
_this.emit('selectend', _this.getLngLatBox(), _this.startEvent, _this.endEvent);
|
|
56
38
|
});
|
|
57
|
-
|
|
58
39
|
_this.scene = scene;
|
|
59
40
|
_this.options = options;
|
|
60
41
|
return _this;
|
|
61
42
|
}
|
|
62
|
-
|
|
63
43
|
_createClass(BoxSelect, [{
|
|
64
44
|
key: "container",
|
|
65
45
|
get: function get() {
|
|
@@ -71,25 +51,20 @@ var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
|
71
51
|
if (this.isEnable) {
|
|
72
52
|
return;
|
|
73
53
|
}
|
|
74
|
-
|
|
75
54
|
var className = this.options.className;
|
|
76
55
|
this.scene.setMapStatus({
|
|
77
56
|
dragEnable: false
|
|
78
57
|
});
|
|
79
58
|
this.container.style.cursor = 'crosshair';
|
|
80
|
-
|
|
81
59
|
if (!this.box) {
|
|
82
60
|
var box = DOM.create('div', undefined, this.container);
|
|
83
61
|
box.classList.add('l7-select-box');
|
|
84
|
-
|
|
85
62
|
if (className) {
|
|
86
63
|
box.classList.add(className);
|
|
87
64
|
}
|
|
88
|
-
|
|
89
65
|
box.style.display = 'none';
|
|
90
66
|
this.box = box;
|
|
91
67
|
}
|
|
92
|
-
|
|
93
68
|
this.scene.on('dragstart', this.onDragStart);
|
|
94
69
|
this.scene.on('dragging', this.onDragging);
|
|
95
70
|
this.scene.on('dragend', this.onDragEnd);
|
|
@@ -101,7 +76,6 @@ var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
|
101
76
|
if (!this.isEnable) {
|
|
102
77
|
return;
|
|
103
78
|
}
|
|
104
|
-
|
|
105
79
|
this.scene.setMapStatus({
|
|
106
80
|
dragEnable: true
|
|
107
81
|
});
|
|
@@ -115,11 +89,11 @@ var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
|
115
89
|
key: "syncBoxBound",
|
|
116
90
|
value: function syncBoxBound() {
|
|
117
91
|
var _this$startEvent = this.startEvent,
|
|
118
|
-
|
|
119
|
-
|
|
92
|
+
x1 = _this$startEvent.x,
|
|
93
|
+
y1 = _this$startEvent.y;
|
|
120
94
|
var _this$endEvent = this.endEvent,
|
|
121
|
-
|
|
122
|
-
|
|
95
|
+
x2 = _this$endEvent.x,
|
|
96
|
+
y2 = _this$endEvent.y;
|
|
123
97
|
var left = Math.min(x1, x2);
|
|
124
98
|
var top = Math.min(y1, y2);
|
|
125
99
|
var width = Math.abs(x1 - x2);
|
|
@@ -133,16 +107,14 @@ var BoxSelect = /*#__PURE__*/function (_EventEmitter) {
|
|
|
133
107
|
key: "getLngLatBox",
|
|
134
108
|
value: function getLngLatBox() {
|
|
135
109
|
var _this$startEvent$lngL = this.startEvent.lngLat,
|
|
136
|
-
|
|
137
|
-
|
|
110
|
+
lng1 = _this$startEvent$lngL.lng,
|
|
111
|
+
lat1 = _this$startEvent$lngL.lat;
|
|
138
112
|
var _this$endEvent$lngLat = this.endEvent.lngLat,
|
|
139
|
-
|
|
140
|
-
|
|
113
|
+
lng2 = _this$endEvent$lngLat.lng,
|
|
114
|
+
lat2 = _this$endEvent$lngLat.lat;
|
|
141
115
|
return getBBoxFromPoints([[lng1, lat1], [lng2, lat2]]);
|
|
142
116
|
}
|
|
143
117
|
}]);
|
|
144
|
-
|
|
145
118
|
return BoxSelect;
|
|
146
119
|
}(EventEmitter);
|
|
147
|
-
|
|
148
120
|
export { BoxSelect as default };
|
package/es/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import { MaskLayer } from '@antv/l7-layers';
|
|
|
10
10
|
import { ReglRendererService } from '@antv/l7-renderer';
|
|
11
11
|
import { DOM, isMini, setMiniScene } from '@antv/l7-utils';
|
|
12
12
|
import BoxSelect, { BoxSelectEventList } from "./boxSelect";
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* 暴露 Scene API
|
|
16
15
|
*
|
|
@@ -26,19 +25,20 @@ import BoxSelect, { BoxSelectEventList } from "./boxSelect";
|
|
|
26
25
|
var Scene = /*#__PURE__*/function () {
|
|
27
26
|
function Scene(config) {
|
|
28
27
|
_classCallCheck(this, Scene);
|
|
29
|
-
|
|
30
28
|
var id = config.id,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
map = config.map,
|
|
30
|
+
canvas = config.canvas,
|
|
31
|
+
hasBaseMap = config.hasBaseMap;
|
|
32
|
+
// 创建场景容器
|
|
35
33
|
var sceneContainer = createSceneContainer();
|
|
36
|
-
this.container = sceneContainer;
|
|
37
|
-
|
|
38
|
-
map.setContainer(sceneContainer, id, canvas, hasBaseMap);
|
|
34
|
+
this.container = sceneContainer;
|
|
35
|
+
// 绑定地图服务
|
|
36
|
+
map.setContainer(sceneContainer, id, canvas, hasBaseMap);
|
|
39
37
|
|
|
40
|
-
|
|
38
|
+
// 绑定渲染引擎服务
|
|
39
|
+
sceneContainer.bind(TYPES.IRendererService).to(ReglRendererService).inSingletonScope();
|
|
41
40
|
|
|
41
|
+
// 依赖注入
|
|
42
42
|
this.sceneService = sceneContainer.get(TYPES.ISceneService);
|
|
43
43
|
this.mapService = sceneContainer.get(TYPES.IMapService);
|
|
44
44
|
this.iconService = sceneContainer.get(TYPES.IIconService);
|
|
@@ -52,18 +52,18 @@ var Scene = /*#__PURE__*/function () {
|
|
|
52
52
|
this.popupService = sceneContainer.get(TYPES.IPopupService);
|
|
53
53
|
this.boxSelect = new BoxSelect(this, {});
|
|
54
54
|
setMiniScene((config === null || config === void 0 ? void 0 : config.isMini) || false);
|
|
55
|
-
|
|
56
55
|
if (isMini) {
|
|
57
56
|
this.sceneService.initMiniScene(config);
|
|
58
57
|
} else {
|
|
59
|
-
this.initComponent(id);
|
|
58
|
+
this.initComponent(id);
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
// 初始化 scene
|
|
61
|
+
this.sceneService.init(config);
|
|
62
|
+
// TODO: 初始化组件
|
|
62
63
|
|
|
63
64
|
this.initControl();
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
|
|
67
67
|
_createClass(Scene, [{
|
|
68
68
|
key: "map",
|
|
69
69
|
get: function get() {
|
|
@@ -114,11 +114,11 @@ var Scene = /*#__PURE__*/function () {
|
|
|
114
114
|
value: function getMapService() {
|
|
115
115
|
return this.mapService;
|
|
116
116
|
}
|
|
117
|
+
|
|
117
118
|
/**
|
|
118
119
|
* 对外暴露 debugService
|
|
119
120
|
* @returns
|
|
120
121
|
*/
|
|
121
|
-
|
|
122
122
|
}, {
|
|
123
123
|
key: "getDebugService",
|
|
124
124
|
value: function getDebugService() {
|
|
@@ -129,23 +129,18 @@ var Scene = /*#__PURE__*/function () {
|
|
|
129
129
|
value: function () {
|
|
130
130
|
var _exportPng = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(type) {
|
|
131
131
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
132
|
-
while (1) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
case "end":
|
|
139
|
-
return _context.stop();
|
|
140
|
-
}
|
|
132
|
+
while (1) switch (_context.prev = _context.next) {
|
|
133
|
+
case 0:
|
|
134
|
+
return _context.abrupt("return", this.sceneService.exportPng(type));
|
|
135
|
+
case 1:
|
|
136
|
+
case "end":
|
|
137
|
+
return _context.stop();
|
|
141
138
|
}
|
|
142
139
|
}, _callee, this);
|
|
143
140
|
}));
|
|
144
|
-
|
|
145
141
|
function exportPng(_x) {
|
|
146
142
|
return _exportPng.apply(this, arguments);
|
|
147
143
|
}
|
|
148
|
-
|
|
149
144
|
return exportPng;
|
|
150
145
|
}()
|
|
151
146
|
}, {
|
|
@@ -153,30 +148,24 @@ var Scene = /*#__PURE__*/function () {
|
|
|
153
148
|
value: function () {
|
|
154
149
|
var _exportMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(type) {
|
|
155
150
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
156
|
-
while (1) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
case "end":
|
|
163
|
-
return _context2.stop();
|
|
164
|
-
}
|
|
151
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
return _context2.abrupt("return", this.sceneService.exportPng(type));
|
|
154
|
+
case 1:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context2.stop();
|
|
165
157
|
}
|
|
166
158
|
}, _callee2, this);
|
|
167
159
|
}));
|
|
168
|
-
|
|
169
160
|
function exportMap(_x2) {
|
|
170
161
|
return _exportMap.apply(this, arguments);
|
|
171
162
|
}
|
|
172
|
-
|
|
173
163
|
return exportMap;
|
|
174
164
|
}()
|
|
175
165
|
}, {
|
|
176
166
|
key: "registerRenderService",
|
|
177
167
|
value: function registerRenderService(render) {
|
|
178
168
|
var _this = this;
|
|
179
|
-
|
|
180
169
|
if (this.sceneService.loaded) {
|
|
181
170
|
var renderSerivce = new render(this);
|
|
182
171
|
renderSerivce.init();
|
|
@@ -191,27 +180,26 @@ var Scene = /*#__PURE__*/function () {
|
|
|
191
180
|
key: "setBgColor",
|
|
192
181
|
value: function setBgColor(color) {
|
|
193
182
|
this.mapService.setBgColor(color);
|
|
194
|
-
}
|
|
183
|
+
}
|
|
195
184
|
|
|
185
|
+
// layer 管理
|
|
196
186
|
}, {
|
|
197
187
|
key: "addLayer",
|
|
198
188
|
value: function addLayer(layer) {
|
|
199
189
|
var _this2 = this;
|
|
200
|
-
|
|
201
190
|
// 为当前图层创建一个容器
|
|
202
191
|
// TODO: 初始化的时候设置 容器
|
|
203
192
|
var layerContainer = createLayerContainer(this.container);
|
|
204
193
|
layer.setContainer(layerContainer, this.container);
|
|
205
|
-
this.sceneService.addLayer(layer);
|
|
194
|
+
this.sceneService.addLayer(layer);
|
|
206
195
|
|
|
196
|
+
// mask 在 scene loaded 之后执行
|
|
207
197
|
if (layer.inited) {
|
|
208
198
|
var maskInstance = this.initMask(layer);
|
|
209
199
|
this.addMask(maskInstance, layer.id);
|
|
210
200
|
} else {
|
|
211
201
|
layer.on('inited', function () {
|
|
212
202
|
var maskInstance = _this2.initMask(layer); // 初始化 mask
|
|
213
|
-
|
|
214
|
-
|
|
215
203
|
_this2.addMask(maskInstance, layer.id);
|
|
216
204
|
});
|
|
217
205
|
}
|
|
@@ -220,17 +208,15 @@ var Scene = /*#__PURE__*/function () {
|
|
|
220
208
|
key: "initMask",
|
|
221
209
|
value: function initMask(layer) {
|
|
222
210
|
var _layer$getLayerConfig = layer.getLayerConfig(),
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
211
|
+
mask = _layer$getLayerConfig.mask,
|
|
212
|
+
maskfence = _layer$getLayerConfig.maskfence,
|
|
213
|
+
_layer$getLayerConfig2 = _layer$getLayerConfig.maskColor,
|
|
214
|
+
maskColor = _layer$getLayerConfig2 === void 0 ? '#000' : _layer$getLayerConfig2,
|
|
215
|
+
_layer$getLayerConfig3 = _layer$getLayerConfig.maskOpacity,
|
|
216
|
+
maskOpacity = _layer$getLayerConfig3 === void 0 ? 0 : _layer$getLayerConfig3;
|
|
230
217
|
if (!mask || !maskfence) {
|
|
231
218
|
return undefined;
|
|
232
219
|
}
|
|
233
|
-
|
|
234
220
|
var maskInstance = new MaskLayer().source(maskfence).shape('fill').style({
|
|
235
221
|
color: maskColor,
|
|
236
222
|
opacity: maskOpacity
|
|
@@ -243,9 +229,7 @@ var Scene = /*#__PURE__*/function () {
|
|
|
243
229
|
if (!mask) {
|
|
244
230
|
return;
|
|
245
231
|
}
|
|
246
|
-
|
|
247
232
|
var parent = this.getLayer(layerId);
|
|
248
|
-
|
|
249
233
|
if (parent) {
|
|
250
234
|
var layerContainer = createLayerContainer(this.container);
|
|
251
235
|
mask.setContainer(layerContainer, this.container);
|
|
@@ -280,24 +264,19 @@ var Scene = /*#__PURE__*/function () {
|
|
|
280
264
|
value: function () {
|
|
281
265
|
var _removeLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(layer, parentLayer) {
|
|
282
266
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
283
|
-
while (1) {
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
case "end":
|
|
291
|
-
return _context3.stop();
|
|
292
|
-
}
|
|
267
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
268
|
+
case 0:
|
|
269
|
+
_context3.next = 2;
|
|
270
|
+
return this.layerService.remove(layer, parentLayer);
|
|
271
|
+
case 2:
|
|
272
|
+
case "end":
|
|
273
|
+
return _context3.stop();
|
|
293
274
|
}
|
|
294
275
|
}, _callee3, this);
|
|
295
276
|
}));
|
|
296
|
-
|
|
297
277
|
function removeLayer(_x3, _x4) {
|
|
298
278
|
return _removeLayer.apply(this, arguments);
|
|
299
279
|
}
|
|
300
|
-
|
|
301
280
|
return removeLayer;
|
|
302
281
|
}()
|
|
303
282
|
}, {
|
|
@@ -305,24 +284,19 @@ var Scene = /*#__PURE__*/function () {
|
|
|
305
284
|
value: function () {
|
|
306
285
|
var _removeAllLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
307
286
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
308
|
-
while (1) {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
case "end":
|
|
316
|
-
return _context4.stop();
|
|
317
|
-
}
|
|
287
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
288
|
+
case 0:
|
|
289
|
+
_context4.next = 2;
|
|
290
|
+
return this.layerService.removeAllLayers();
|
|
291
|
+
case 2:
|
|
292
|
+
case "end":
|
|
293
|
+
return _context4.stop();
|
|
318
294
|
}
|
|
319
295
|
}, _callee4, this);
|
|
320
296
|
}));
|
|
321
|
-
|
|
322
297
|
function removeAllLayer() {
|
|
323
298
|
return _removeAllLayer.apply(this, arguments);
|
|
324
299
|
}
|
|
325
|
-
|
|
326
300
|
return removeAllLayer;
|
|
327
301
|
}()
|
|
328
302
|
}, {
|
|
@@ -334,14 +308,14 @@ var Scene = /*#__PURE__*/function () {
|
|
|
334
308
|
key: "setEnableRender",
|
|
335
309
|
value: function setEnableRender(flag) {
|
|
336
310
|
this.layerService.setEnableRender(flag);
|
|
337
|
-
}
|
|
311
|
+
}
|
|
338
312
|
|
|
313
|
+
// asset method
|
|
339
314
|
/**
|
|
340
315
|
* 为 layer/point/text 支持 iconfont 模式支持
|
|
341
316
|
* @param fontUnicode
|
|
342
317
|
* @param name
|
|
343
318
|
*/
|
|
344
|
-
|
|
345
319
|
}, {
|
|
346
320
|
key: "addIconFont",
|
|
347
321
|
value: function addIconFont(name, fontUnicode) {
|
|
@@ -351,12 +325,10 @@ var Scene = /*#__PURE__*/function () {
|
|
|
351
325
|
key: "addIconFonts",
|
|
352
326
|
value: function addIconFonts(options) {
|
|
353
327
|
var _this3 = this;
|
|
354
|
-
|
|
355
328
|
options.forEach(function (_ref) {
|
|
356
329
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
330
|
+
name = _ref2[0],
|
|
331
|
+
fontUnicode = _ref2[1];
|
|
360
332
|
_this3.fontService.addIconFont(name, fontUnicode);
|
|
361
333
|
});
|
|
362
334
|
}
|
|
@@ -365,12 +337,10 @@ var Scene = /*#__PURE__*/function () {
|
|
|
365
337
|
* @param fontFamily
|
|
366
338
|
* @param fontPath
|
|
367
339
|
*/
|
|
368
|
-
|
|
369
340
|
}, {
|
|
370
341
|
key: "addFontFace",
|
|
371
342
|
value: function addFontFace(fontFamily, fontPath) {
|
|
372
343
|
var _this4 = this;
|
|
373
|
-
|
|
374
344
|
this.fontService.once('fontloaded', function (e) {
|
|
375
345
|
_this4.emit('fontloaded', e);
|
|
376
346
|
});
|
|
@@ -381,36 +351,28 @@ var Scene = /*#__PURE__*/function () {
|
|
|
381
351
|
value: function () {
|
|
382
352
|
var _addImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, img) {
|
|
383
353
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
384
|
-
while (1) {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
_context5.next = 5;
|
|
389
|
-
break;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
_context5.next = 3;
|
|
393
|
-
return this.iconService.addImage(id, img);
|
|
394
|
-
|
|
395
|
-
case 3:
|
|
396
|
-
_context5.next = 6;
|
|
354
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
355
|
+
case 0:
|
|
356
|
+
if (isMini) {
|
|
357
|
+
_context5.next = 5;
|
|
397
358
|
break;
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
359
|
+
}
|
|
360
|
+
_context5.next = 3;
|
|
361
|
+
return this.iconService.addImage(id, img);
|
|
362
|
+
case 3:
|
|
363
|
+
_context5.next = 6;
|
|
364
|
+
break;
|
|
365
|
+
case 5:
|
|
366
|
+
this.iconService.addImageMini(id, img, this.sceneService);
|
|
367
|
+
case 6:
|
|
368
|
+
case "end":
|
|
369
|
+
return _context5.stop();
|
|
406
370
|
}
|
|
407
371
|
}, _callee5, this);
|
|
408
372
|
}));
|
|
409
|
-
|
|
410
373
|
function addImage(_x5, _x6) {
|
|
411
374
|
return _addImage.apply(this, arguments);
|
|
412
375
|
}
|
|
413
|
-
|
|
414
376
|
return addImage;
|
|
415
377
|
}()
|
|
416
378
|
}, {
|
|
@@ -427,8 +389,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
427
389
|
key: "addIconFontGlyphs",
|
|
428
390
|
value: function addIconFontGlyphs(fontFamily, glyphs) {
|
|
429
391
|
this.fontService.addIconGlyphs(glyphs);
|
|
430
|
-
}
|
|
392
|
+
}
|
|
431
393
|
|
|
394
|
+
// map control method
|
|
432
395
|
}, {
|
|
433
396
|
key: "addControl",
|
|
434
397
|
value: function addControl(ctr) {
|
|
@@ -443,8 +406,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
443
406
|
key: "getControlByName",
|
|
444
407
|
value: function getControlByName(name) {
|
|
445
408
|
return this.controlService.getControlByName(name);
|
|
446
|
-
}
|
|
409
|
+
}
|
|
447
410
|
|
|
411
|
+
// marker
|
|
448
412
|
}, {
|
|
449
413
|
key: "addMarker",
|
|
450
414
|
value: function addMarker(marker) {
|
|
@@ -480,7 +444,6 @@ var Scene = /*#__PURE__*/function () {
|
|
|
480
444
|
value: function on(type, handle) {
|
|
481
445
|
if (BoxSelectEventList.includes(type)) {
|
|
482
446
|
var _this$boxSelect;
|
|
483
|
-
|
|
484
447
|
(_this$boxSelect = this.boxSelect) === null || _this$boxSelect === void 0 ? void 0 : _this$boxSelect.on(type, handle);
|
|
485
448
|
} else if (SceneEventList.includes(type)) {
|
|
486
449
|
this.sceneService.on(type, handle);
|
|
@@ -493,7 +456,6 @@ var Scene = /*#__PURE__*/function () {
|
|
|
493
456
|
value: function once(type, handle) {
|
|
494
457
|
if (BoxSelectEventList.includes(type)) {
|
|
495
458
|
var _this$boxSelect2;
|
|
496
|
-
|
|
497
459
|
(_this$boxSelect2 = this.boxSelect) === null || _this$boxSelect2 === void 0 ? void 0 : _this$boxSelect2.once(type, handle);
|
|
498
460
|
} else if (SceneEventList.includes(type)) {
|
|
499
461
|
this.sceneService.once(type, handle);
|
|
@@ -511,15 +473,15 @@ var Scene = /*#__PURE__*/function () {
|
|
|
511
473
|
value: function off(type, handle) {
|
|
512
474
|
if (BoxSelectEventList.includes(type)) {
|
|
513
475
|
var _this$boxSelect3;
|
|
514
|
-
|
|
515
476
|
(_this$boxSelect3 = this.boxSelect) === null || _this$boxSelect3 === void 0 ? void 0 : _this$boxSelect3.off(type, handle);
|
|
516
477
|
} else if (SceneEventList.includes(type)) {
|
|
517
478
|
this.sceneService.off(type, handle);
|
|
518
479
|
} else {
|
|
519
480
|
this.mapService.off(type, handle);
|
|
520
481
|
}
|
|
521
|
-
}
|
|
482
|
+
}
|
|
522
483
|
|
|
484
|
+
// implements IMapController
|
|
523
485
|
}, {
|
|
524
486
|
key: "getZoom",
|
|
525
487
|
value: function getZoom() {
|
|
@@ -594,10 +556,10 @@ var Scene = /*#__PURE__*/function () {
|
|
|
594
556
|
key: "fitBounds",
|
|
595
557
|
value: function fitBounds(bound, options) {
|
|
596
558
|
var _this$sceneService$ge = this.sceneService.getSceneConfig(),
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
559
|
+
fitBoundsOptions = _this$sceneService$ge.fitBoundsOptions,
|
|
560
|
+
animate = _this$sceneService$ge.animate;
|
|
561
|
+
this.mapService.fitBounds(bound,
|
|
562
|
+
// 选项优先级:用户传入,覆盖animate直接配置,覆盖Scene配置项传入
|
|
601
563
|
options || _objectSpread(_objectSpread({}, fitBoundsOptions), {}, {
|
|
602
564
|
animate: animate
|
|
603
565
|
}));
|
|
@@ -616,8 +578,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
616
578
|
key: "setMapStatus",
|
|
617
579
|
value: function setMapStatus(options) {
|
|
618
580
|
this.mapService.setMapStatus(options);
|
|
619
|
-
}
|
|
581
|
+
}
|
|
620
582
|
|
|
583
|
+
// conversion Method
|
|
621
584
|
}, {
|
|
622
585
|
key: "pixelToLngLat",
|
|
623
586
|
value: function pixelToLngLat(pixel) {
|
|
@@ -641,14 +604,16 @@ var Scene = /*#__PURE__*/function () {
|
|
|
641
604
|
}, {
|
|
642
605
|
key: "destroy",
|
|
643
606
|
value: function destroy() {
|
|
644
|
-
this.sceneService.destroy();
|
|
607
|
+
this.sceneService.destroy();
|
|
608
|
+
// TODO: 清理其他 Service 例如 IconService
|
|
645
609
|
}
|
|
646
610
|
}, {
|
|
647
611
|
key: "registerPostProcessingPass",
|
|
648
612
|
value: function registerPostProcessingPass(constructor, name) {
|
|
649
613
|
this.container.bind(TYPES.IPostProcessingPass).to(constructor).whenTargetNamed(name);
|
|
650
|
-
}
|
|
614
|
+
}
|
|
651
615
|
|
|
616
|
+
// 控制 shader pick 计算
|
|
652
617
|
}, {
|
|
653
618
|
key: "enableShaderPick",
|
|
654
619
|
value: function enableShaderPick() {
|
|
@@ -663,10 +628,8 @@ var Scene = /*#__PURE__*/function () {
|
|
|
663
628
|
key: "enableBoxSelect",
|
|
664
629
|
value: function enableBoxSelect() {
|
|
665
630
|
var _this5 = this;
|
|
666
|
-
|
|
667
631
|
var once = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
668
632
|
this.boxSelect.enable();
|
|
669
|
-
|
|
670
633
|
if (once) {
|
|
671
634
|
this.boxSelect.once('selectend', function () {
|
|
672
635
|
_this5.disableBoxSelect();
|
|
@@ -677,8 +640,9 @@ var Scene = /*#__PURE__*/function () {
|
|
|
677
640
|
key: "disableBoxSelect",
|
|
678
641
|
value: function disableBoxSelect() {
|
|
679
642
|
this.boxSelect.disable();
|
|
680
|
-
}
|
|
643
|
+
}
|
|
681
644
|
|
|
645
|
+
// get current point size info
|
|
682
646
|
}, {
|
|
683
647
|
key: "getPointSizeRange",
|
|
684
648
|
value: function getPointSizeRange() {
|
|
@@ -697,9 +661,8 @@ var Scene = /*#__PURE__*/function () {
|
|
|
697
661
|
key: "initControl",
|
|
698
662
|
value: function initControl() {
|
|
699
663
|
var _this$sceneService$ge2 = this.sceneService.getSceneConfig(),
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
664
|
+
logoVisible = _this$sceneService$ge2.logoVisible,
|
|
665
|
+
logoPosition = _this$sceneService$ge2.logoPosition;
|
|
703
666
|
if (logoVisible) {
|
|
704
667
|
this.addControl(new Logo({
|
|
705
668
|
position: logoPosition
|
|
@@ -707,8 +670,6 @@ var Scene = /*#__PURE__*/function () {
|
|
|
707
670
|
}
|
|
708
671
|
}
|
|
709
672
|
}]);
|
|
710
|
-
|
|
711
673
|
return Scene;
|
|
712
674
|
}();
|
|
713
|
-
|
|
714
675
|
export { Scene };
|
package/lib/boxSelect.js
CHANGED
|
@@ -34,7 +34,12 @@ var BoxSelect = class extends import_eventemitter3.EventEmitter {
|
|
|
34
34
|
this.box.style.display = "block";
|
|
35
35
|
this.startEvent = this.endEvent = e;
|
|
36
36
|
this.syncBoxBound();
|
|
37
|
-
this.emit(
|
|
37
|
+
this.emit(
|
|
38
|
+
"selectstart",
|
|
39
|
+
this.getLngLatBox(),
|
|
40
|
+
this.startEvent,
|
|
41
|
+
this.endEvent
|
|
42
|
+
);
|
|
38
43
|
};
|
|
39
44
|
this.onDragging = (e) => {
|
|
40
45
|
this.endEvent = e;
|
|
@@ -62,7 +67,11 @@ var BoxSelect = class extends import_eventemitter3.EventEmitter {
|
|
|
62
67
|
});
|
|
63
68
|
this.container.style.cursor = "crosshair";
|
|
64
69
|
if (!this.box) {
|
|
65
|
-
const box = import_l7_utils.DOM.create(
|
|
70
|
+
const box = import_l7_utils.DOM.create(
|
|
71
|
+
"div",
|
|
72
|
+
void 0,
|
|
73
|
+
this.container
|
|
74
|
+
);
|
|
66
75
|
box.classList.add("l7-select-box");
|
|
67
76
|
if (className) {
|
|
68
77
|
box.classList.add(className);
|
package/lib/index.js
CHANGED
|
@@ -16,7 +16,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
}
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
20
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
28
|
|
|
22
29
|
// src/index.ts
|
|
@@ -39,15 +46,23 @@ var Scene = class {
|
|
|
39
46
|
map.setContainer(sceneContainer, id, canvas, hasBaseMap);
|
|
40
47
|
sceneContainer.bind(import_l7_core.TYPES.IRendererService).to(import_l7_renderer.ReglRendererService).inSingletonScope();
|
|
41
48
|
this.sceneService = sceneContainer.get(import_l7_core.TYPES.ISceneService);
|
|
42
|
-
this.mapService = sceneContainer.get(
|
|
49
|
+
this.mapService = sceneContainer.get(
|
|
50
|
+
import_l7_core.TYPES.IMapService
|
|
51
|
+
);
|
|
43
52
|
this.iconService = sceneContainer.get(import_l7_core.TYPES.IIconService);
|
|
44
53
|
this.fontService = sceneContainer.get(import_l7_core.TYPES.IFontService);
|
|
45
|
-
this.controlService = sceneContainer.get(
|
|
54
|
+
this.controlService = sceneContainer.get(
|
|
55
|
+
import_l7_core.TYPES.IControlService
|
|
56
|
+
);
|
|
46
57
|
this.layerService = sceneContainer.get(import_l7_core.TYPES.ILayerService);
|
|
47
58
|
this.debugService = sceneContainer.get(import_l7_core.TYPES.IDebugService);
|
|
48
59
|
this.debugService.setEnable(config.debug);
|
|
49
|
-
this.markerService = sceneContainer.get(
|
|
50
|
-
|
|
60
|
+
this.markerService = sceneContainer.get(
|
|
61
|
+
import_l7_core.TYPES.IMarkerService
|
|
62
|
+
);
|
|
63
|
+
this.interactionService = sceneContainer.get(
|
|
64
|
+
import_l7_core.TYPES.IInteractionService
|
|
65
|
+
);
|
|
51
66
|
this.popupService = sceneContainer.get(import_l7_core.TYPES.IPopupService);
|
|
52
67
|
this.boxSelect = new import_boxSelect.default(this, {});
|
|
53
68
|
(0, import_l7_utils.setMiniScene)((config == null ? void 0 : config.isMini) || false);
|
|
@@ -89,6 +104,10 @@ var Scene = class {
|
|
|
89
104
|
getMapService() {
|
|
90
105
|
return this.mapService;
|
|
91
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* 对外暴露 debugService
|
|
109
|
+
* @returns
|
|
110
|
+
*/
|
|
92
111
|
getDebugService() {
|
|
93
112
|
return this.debugService;
|
|
94
113
|
}
|
|
@@ -112,6 +131,7 @@ var Scene = class {
|
|
|
112
131
|
setBgColor(color) {
|
|
113
132
|
this.mapService.setBgColor(color);
|
|
114
133
|
}
|
|
134
|
+
// layer 管理
|
|
115
135
|
addLayer(layer) {
|
|
116
136
|
const layerContainer = (0, import_l7_core.createLayerContainer)(this.container);
|
|
117
137
|
layer.setContainer(layerContainer, this.container);
|
|
@@ -180,6 +200,12 @@ var Scene = class {
|
|
|
180
200
|
setEnableRender(flag) {
|
|
181
201
|
this.layerService.setEnableRender(flag);
|
|
182
202
|
}
|
|
203
|
+
// asset method
|
|
204
|
+
/**
|
|
205
|
+
* 为 layer/point/text 支持 iconfont 模式支持
|
|
206
|
+
* @param fontUnicode
|
|
207
|
+
* @param name
|
|
208
|
+
*/
|
|
183
209
|
addIconFont(name, fontUnicode) {
|
|
184
210
|
this.fontService.addIconFont(name, fontUnicode);
|
|
185
211
|
}
|
|
@@ -188,6 +214,11 @@ var Scene = class {
|
|
|
188
214
|
this.fontService.addIconFont(name, fontUnicode);
|
|
189
215
|
});
|
|
190
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* 用户自定义添加第三方字体
|
|
219
|
+
* @param fontFamily
|
|
220
|
+
* @param fontPath
|
|
221
|
+
*/
|
|
191
222
|
addFontFace(fontFamily, fontPath) {
|
|
192
223
|
this.fontService.once("fontloaded", (e) => {
|
|
193
224
|
this.emit("fontloaded", e);
|
|
@@ -210,6 +241,7 @@ var Scene = class {
|
|
|
210
241
|
addIconFontGlyphs(fontFamily, glyphs) {
|
|
211
242
|
this.fontService.addIconGlyphs(glyphs);
|
|
212
243
|
}
|
|
244
|
+
// map control method
|
|
213
245
|
addControl(ctr) {
|
|
214
246
|
this.controlService.addControl(ctr, this.container);
|
|
215
247
|
}
|
|
@@ -219,6 +251,7 @@ var Scene = class {
|
|
|
219
251
|
getControlByName(name) {
|
|
220
252
|
return this.controlService.getControlByName(name);
|
|
221
253
|
}
|
|
254
|
+
// marker
|
|
222
255
|
addMarker(marker) {
|
|
223
256
|
this.markerService.addMarker(marker);
|
|
224
257
|
}
|
|
@@ -270,6 +303,7 @@ var Scene = class {
|
|
|
270
303
|
this.mapService.off(type, handle);
|
|
271
304
|
}
|
|
272
305
|
}
|
|
306
|
+
// implements IMapController
|
|
273
307
|
getZoom() {
|
|
274
308
|
return this.mapService.getZoom();
|
|
275
309
|
}
|
|
@@ -314,10 +348,14 @@ var Scene = class {
|
|
|
314
348
|
}
|
|
315
349
|
fitBounds(bound, options) {
|
|
316
350
|
const { fitBoundsOptions, animate } = this.sceneService.getSceneConfig();
|
|
317
|
-
this.mapService.fitBounds(
|
|
318
|
-
|
|
319
|
-
animate
|
|
320
|
-
|
|
351
|
+
this.mapService.fitBounds(
|
|
352
|
+
bound,
|
|
353
|
+
// 选项优先级:用户传入,覆盖animate直接配置,覆盖Scene配置项传入
|
|
354
|
+
options || {
|
|
355
|
+
...fitBoundsOptions,
|
|
356
|
+
animate
|
|
357
|
+
}
|
|
358
|
+
);
|
|
321
359
|
}
|
|
322
360
|
setZoomAndCenter(zoom, center) {
|
|
323
361
|
this.mapService.setZoomAndCenter(zoom, center);
|
|
@@ -328,6 +366,7 @@ var Scene = class {
|
|
|
328
366
|
setMapStatus(options) {
|
|
329
367
|
this.mapService.setMapStatus(options);
|
|
330
368
|
}
|
|
369
|
+
// conversion Method
|
|
331
370
|
pixelToLngLat(pixel) {
|
|
332
371
|
return this.mapService.pixelToLngLat(pixel);
|
|
333
372
|
}
|
|
@@ -346,6 +385,7 @@ var Scene = class {
|
|
|
346
385
|
registerPostProcessingPass(constructor, name) {
|
|
347
386
|
this.container.bind(import_l7_core.TYPES.IPostProcessingPass).to(constructor).whenTargetNamed(name);
|
|
348
387
|
}
|
|
388
|
+
// 控制 shader pick 计算
|
|
349
389
|
enableShaderPick() {
|
|
350
390
|
this.layerService.enableShaderPick();
|
|
351
391
|
}
|
|
@@ -363,13 +403,17 @@ var Scene = class {
|
|
|
363
403
|
disableBoxSelect() {
|
|
364
404
|
this.boxSelect.disable();
|
|
365
405
|
}
|
|
406
|
+
// get current point size info
|
|
366
407
|
getPointSizeRange() {
|
|
367
408
|
return this.sceneService.getPointSizeRange();
|
|
368
409
|
}
|
|
369
410
|
initComponent(id) {
|
|
370
|
-
this.controlService.init(
|
|
371
|
-
|
|
372
|
-
|
|
411
|
+
this.controlService.init(
|
|
412
|
+
{
|
|
413
|
+
container: import_l7_utils.DOM.getContainer(id)
|
|
414
|
+
},
|
|
415
|
+
this.container
|
|
416
|
+
);
|
|
373
417
|
this.markerService.init(this.container);
|
|
374
418
|
this.popupService.init(this.container);
|
|
375
419
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-scene",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.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.15.
|
|
27
|
-
"@antv/l7-core": "2.15.
|
|
28
|
-
"@antv/l7-layers": "2.15.
|
|
29
|
-
"@antv/l7-maps": "2.15.
|
|
30
|
-
"@antv/l7-renderer": "2.15.
|
|
31
|
-
"@antv/l7-utils": "2.15.
|
|
26
|
+
"@antv/l7-component": "2.15.3",
|
|
27
|
+
"@antv/l7-core": "2.15.3",
|
|
28
|
+
"@antv/l7-layers": "2.15.3",
|
|
29
|
+
"@antv/l7-maps": "2.15.3",
|
|
30
|
+
"@antv/l7-renderer": "2.15.3",
|
|
31
|
+
"@antv/l7-utils": "2.15.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.15.
|
|
39
|
+
"@antv/l7-test-utils": "2.15.3"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "615a788e45363d5f811d318e02e5959a1583a4cf",
|
|
42
42
|
"publishConfig": {
|
|
43
43
|
"access": "public"
|
|
44
44
|
}
|