@antv/l7-layers 2.14.2 → 2.14.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.
- package/es/core/BaseLayer.js +2 -2
- package/es/core/LayerPickService.js +3 -31
- package/es/tile/tileFactory/index.js +7 -5
- package/es/tile/tileLayer/BaseLayer.d.ts +1 -1
- package/es/tile/tileLayer/BaseLayer.js +63 -62
- package/lib/core/BaseLayer.js +2 -2
- package/lib/core/LayerPickService.js +3 -33
- package/lib/tile/tileFactory/index.js +8 -5
- package/lib/tile/tileLayer/BaseLayer.js +62 -62
- package/package.json +7 -7
package/es/core/BaseLayer.js
CHANGED
|
@@ -524,7 +524,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
524
524
|
key: "filter",
|
|
525
525
|
value: function filter(field, values, updateOptions) {
|
|
526
526
|
var flag = this.updateStyleAttribute('filter', field, values, updateOptions);
|
|
527
|
-
this.dataState.dataSourceNeedUpdate = flag;
|
|
527
|
+
this.dataState.dataSourceNeedUpdate = flag && this.inited;
|
|
528
528
|
return this;
|
|
529
529
|
}
|
|
530
530
|
}, {
|
|
@@ -535,7 +535,7 @@ var BaseLayer = (_dec = lazyInject(TYPES.IGlobalConfigService), (_class = /*#__P
|
|
|
535
535
|
values: values
|
|
536
536
|
};
|
|
537
537
|
var flag = this.updateStyleAttribute('shape', field, values, updateOptions);
|
|
538
|
-
this.dataState.dataSourceNeedUpdate = flag;
|
|
538
|
+
this.dataState.dataSourceNeedUpdate = flag && this.inited;
|
|
539
539
|
return this;
|
|
540
540
|
}
|
|
541
541
|
}, {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
2
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
5
4
|
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
6
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
5
|
import { TYPES } from '@antv/l7-core';
|
|
8
6
|
import { lngLatInExtent } from '@antv/l7-utils';
|
|
9
7
|
|
|
@@ -17,6 +15,8 @@ var BaseLayerPickService = /*#__PURE__*/function () {
|
|
|
17
15
|
_createClass(BaseLayerPickService, [{
|
|
18
16
|
key: "pickRender",
|
|
19
17
|
value: function pickRender(target) {
|
|
18
|
+
var container = this.layer.getContainer();
|
|
19
|
+
var layerService = container.get(TYPES.ILayerService);
|
|
20
20
|
var layer = this.layer; // 瓦片图层的拾取绘制
|
|
21
21
|
|
|
22
22
|
if (layer.tileLayer) {
|
|
@@ -24,35 +24,7 @@ var BaseLayerPickService = /*#__PURE__*/function () {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
layer.hooks.beforePickingEncode.call();
|
|
27
|
-
|
|
28
|
-
if (layer.masks.length > 0) {
|
|
29
|
-
// 若存在 mask,则在 pick 阶段的绘制也启用
|
|
30
|
-
layer.masks.filter(function (mask) {
|
|
31
|
-
return mask.inited;
|
|
32
|
-
}).forEach( /*#__PURE__*/function () {
|
|
33
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(m) {
|
|
34
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
|
-
while (1) {
|
|
36
|
-
switch (_context.prev = _context.next) {
|
|
37
|
-
case 0:
|
|
38
|
-
m.render({
|
|
39
|
-
isStencil: true
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
case 1:
|
|
43
|
-
case "end":
|
|
44
|
-
return _context.stop();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}, _callee);
|
|
48
|
-
}));
|
|
49
|
-
|
|
50
|
-
return function (_x) {
|
|
51
|
-
return _ref.apply(this, arguments);
|
|
52
|
-
};
|
|
53
|
-
}());
|
|
54
|
-
}
|
|
55
|
-
|
|
27
|
+
layerService.renderTileLayerMask(layer);
|
|
56
28
|
layer.renderModels({
|
|
57
29
|
ispick: true
|
|
58
30
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RasterTileType } from '@antv/l7-core';
|
|
1
2
|
import DebugTile from "./DebugTile";
|
|
2
3
|
import ImageTile from "./ImageTile";
|
|
3
4
|
import MaskLayer from "./MaskTile";
|
|
@@ -28,15 +29,16 @@ export function getTileFactory(layer) {
|
|
|
28
29
|
var dataType = layer.getSource().parser.dataType;
|
|
29
30
|
|
|
30
31
|
switch (dataType) {
|
|
31
|
-
case
|
|
32
|
-
case
|
|
32
|
+
case RasterTileType.RGB:
|
|
33
|
+
case RasterTileType.CUSTOMRGB:
|
|
33
34
|
return RasterRGBTile;
|
|
34
35
|
|
|
35
|
-
case
|
|
36
|
-
case
|
|
36
|
+
case RasterTileType.ARRAYBUFFER:
|
|
37
|
+
case RasterTileType.CUSTOMARRAYBUFFER:
|
|
37
38
|
return RasterTile;
|
|
38
39
|
|
|
39
|
-
case
|
|
40
|
+
case RasterTileType.TERRAINRGB:
|
|
41
|
+
case RasterTileType.CUSTOMTERRAINRGB:
|
|
40
42
|
return RasterTerrainRGBTile;
|
|
41
43
|
|
|
42
44
|
default:
|
|
@@ -18,7 +18,7 @@ export default class BaseTileLayer {
|
|
|
18
18
|
};
|
|
19
19
|
constructor(parent: ILayer);
|
|
20
20
|
protected initTileSetManager(): void;
|
|
21
|
-
protected mapchange()
|
|
21
|
+
protected mapchange: () => void;
|
|
22
22
|
protected getCurrentView(): {
|
|
23
23
|
latLonBounds: [number, number, number, number];
|
|
24
24
|
zoom: number;
|
|
@@ -13,10 +13,49 @@ import { getTileFactory } from "../tileFactory";
|
|
|
13
13
|
var BaseTileLayer = /*#__PURE__*/function () {
|
|
14
14
|
// 瓦片数据管理器
|
|
15
15
|
function BaseTileLayer(parent) {
|
|
16
|
+
var _this = this;
|
|
17
|
+
|
|
16
18
|
_classCallCheck(this, BaseTileLayer);
|
|
17
19
|
|
|
18
20
|
_defineProperty(this, "initedTileset", false);
|
|
19
21
|
|
|
22
|
+
_defineProperty(this, "mapchange", function () {
|
|
23
|
+
var _this$tilesetManager;
|
|
24
|
+
|
|
25
|
+
var _this$getCurrentView = _this.getCurrentView(),
|
|
26
|
+
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
27
|
+
zoom = _this$getCurrentView.zoom;
|
|
28
|
+
|
|
29
|
+
if (_this.mapService.version === 'GAODE1.x') {
|
|
30
|
+
var _this$parent$getLayer = _this.parent.getLayerConfig(),
|
|
31
|
+
visible = _this$parent$getLayer.visible;
|
|
32
|
+
|
|
33
|
+
if (zoom < 2 && visible) {
|
|
34
|
+
_this.parent.updateLayerConfig({
|
|
35
|
+
visible: false
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
_this.layerService.reRender();
|
|
39
|
+
} else if (zoom >= 2 && !visible) {
|
|
40
|
+
_this.parent.updateLayerConfig({
|
|
41
|
+
visible: true
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
_this.layerService.reRender();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (_this.lastViewStates && _this.lastViewStates.zoom === zoom && _this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_this.lastViewStates = {
|
|
53
|
+
zoom: zoom,
|
|
54
|
+
latLonBounds: latLonBounds
|
|
55
|
+
};
|
|
56
|
+
(_this$tilesetManager = _this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.throttleUpdate(zoom, latLonBounds);
|
|
57
|
+
});
|
|
58
|
+
|
|
20
59
|
_defineProperty(this, "viewchange", debounce(this.mapchange, 24));
|
|
21
60
|
|
|
22
61
|
this.parent = parent;
|
|
@@ -46,7 +85,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
46
85
|
_createClass(BaseTileLayer, [{
|
|
47
86
|
key: "initTileSetManager",
|
|
48
87
|
value: function initTileSetManager() {
|
|
49
|
-
var _this$
|
|
88
|
+
var _this$tilesetManager2;
|
|
50
89
|
|
|
51
90
|
var source = this.parent.getSource();
|
|
52
91
|
this.tilesetManager = source.tileset;
|
|
@@ -56,47 +95,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
56
95
|
this.initedTileset = true;
|
|
57
96
|
}
|
|
58
97
|
|
|
59
|
-
var _this$getCurrentView = this.getCurrentView(),
|
|
60
|
-
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
61
|
-
zoom = _this$getCurrentView.zoom;
|
|
62
|
-
|
|
63
|
-
(_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
|
|
64
|
-
}
|
|
65
|
-
}, {
|
|
66
|
-
key: "mapchange",
|
|
67
|
-
value: function mapchange() {
|
|
68
|
-
var _this$tilesetManager2;
|
|
69
|
-
|
|
70
98
|
var _this$getCurrentView2 = this.getCurrentView(),
|
|
71
99
|
latLonBounds = _this$getCurrentView2.latLonBounds,
|
|
72
100
|
zoom = _this$getCurrentView2.zoom;
|
|
73
101
|
|
|
74
|
-
|
|
75
|
-
var _this$parent$getLayer = this.parent.getLayerConfig(),
|
|
76
|
-
visible = _this$parent$getLayer.visible;
|
|
77
|
-
|
|
78
|
-
if (zoom < 2 && visible) {
|
|
79
|
-
this.parent.updateLayerConfig({
|
|
80
|
-
visible: false
|
|
81
|
-
});
|
|
82
|
-
this.layerService.reRender();
|
|
83
|
-
} else if (zoom >= 2 && !visible) {
|
|
84
|
-
this.parent.updateLayerConfig({
|
|
85
|
-
visible: true
|
|
86
|
-
});
|
|
87
|
-
this.layerService.reRender();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
this.lastViewStates = {
|
|
96
|
-
zoom: zoom,
|
|
97
|
-
latLonBounds: latLonBounds
|
|
98
|
-
};
|
|
99
|
-
(_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.throttleUpdate(zoom, latLonBounds);
|
|
102
|
+
(_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds);
|
|
100
103
|
}
|
|
101
104
|
}, {
|
|
102
105
|
key: "getCurrentView",
|
|
@@ -112,7 +115,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
112
115
|
}, {
|
|
113
116
|
key: "bindTilesetEvent",
|
|
114
117
|
value: function bindTilesetEvent() {
|
|
115
|
-
var
|
|
118
|
+
var _this2 = this;
|
|
116
119
|
|
|
117
120
|
// 瓦片数据加载成功
|
|
118
121
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -121,25 +124,21 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
121
124
|
|
|
122
125
|
this.tilesetManager.on('tile-unload', function (tile) {
|
|
123
126
|
// 将事件抛出,图层上可以监听使用
|
|
124
|
-
|
|
127
|
+
_this2.tileUnLoad(tile);
|
|
125
128
|
}); // 瓦片数据加载失败
|
|
126
129
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
127
130
|
|
|
128
131
|
this.tilesetManager.on('tile-error', function (error, tile) {
|
|
129
132
|
// 将事件抛出,图层上可以监听使用
|
|
130
|
-
|
|
133
|
+
_this2.tileError(error);
|
|
131
134
|
}); // 瓦片显隐状态更新
|
|
132
135
|
|
|
133
136
|
this.tilesetManager.on('tile-update', function () {
|
|
134
|
-
|
|
137
|
+
_this2.tileUpdate();
|
|
135
138
|
}); // 地图视野发生改变
|
|
136
139
|
|
|
137
|
-
this.mapService.on('zoomend',
|
|
138
|
-
|
|
139
|
-
});
|
|
140
|
-
this.mapService.on('moveend', function () {
|
|
141
|
-
return _this.viewchange();
|
|
142
|
-
});
|
|
140
|
+
this.mapService.on('zoomend', this.mapchange);
|
|
141
|
+
this.mapService.on('moveend', this.viewchange);
|
|
143
142
|
}
|
|
144
143
|
}, {
|
|
145
144
|
key: "render",
|
|
@@ -177,6 +176,8 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
177
176
|
value: function destroy() {
|
|
178
177
|
var _this$tilesetManager3;
|
|
179
178
|
|
|
179
|
+
this.mapService.off('zoomend', this.mapchange);
|
|
180
|
+
this.mapService.off('moveend', this.viewchange);
|
|
180
181
|
(_this$tilesetManager3 = this.tilesetManager) === null || _this$tilesetManager3 === void 0 ? void 0 : _this$tilesetManager3.destroy();
|
|
181
182
|
this.tileLayerService.destroy();
|
|
182
183
|
}
|
|
@@ -189,7 +190,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
189
190
|
key: "tileUpdate",
|
|
190
191
|
value: function () {
|
|
191
192
|
var _tileUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
192
|
-
var
|
|
193
|
+
var _this3 = this;
|
|
193
194
|
|
|
194
195
|
var minZoom, maxZoom;
|
|
195
196
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -224,25 +225,25 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
224
225
|
while (1) {
|
|
225
226
|
switch (_context.prev = _context.next) {
|
|
226
227
|
case 0:
|
|
227
|
-
if (
|
|
228
|
+
if (_this3.tileLayerService.hasTile(tile.key)) {
|
|
228
229
|
_context.next = 9;
|
|
229
230
|
break;
|
|
230
231
|
}
|
|
231
232
|
|
|
232
|
-
tileInstance = getTileFactory(
|
|
233
|
-
tileLayer = new tileInstance(tile,
|
|
233
|
+
tileInstance = getTileFactory(_this3.parent);
|
|
234
|
+
tileLayer = new tileInstance(tile, _this3.parent);
|
|
234
235
|
_context.next = 5;
|
|
235
236
|
return tileLayer.initTileLayer();
|
|
236
237
|
|
|
237
238
|
case 5:
|
|
238
|
-
|
|
239
|
+
_this3.tilePickService.setPickState();
|
|
239
240
|
|
|
240
241
|
if (tileLayer.getLayers().length !== 0) {
|
|
241
|
-
|
|
242
|
+
_this3.tileLayerService.addTile(tileLayer);
|
|
242
243
|
|
|
243
|
-
|
|
244
|
+
_this3.tileLayerService.updateTileVisible(tile);
|
|
244
245
|
|
|
245
|
-
|
|
246
|
+
_this3.layerService.reRender();
|
|
246
247
|
}
|
|
247
248
|
|
|
248
249
|
_context.next = 12;
|
|
@@ -250,11 +251,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
250
251
|
|
|
251
252
|
case 9:
|
|
252
253
|
// 已加载瓦片
|
|
253
|
-
|
|
254
|
+
_this3.tileLayerService.updateTileVisible(tile);
|
|
254
255
|
|
|
255
|
-
|
|
256
|
+
_this3.tilePickService.setPickState();
|
|
256
257
|
|
|
257
|
-
|
|
258
|
+
_this3.layerService.reRender();
|
|
258
259
|
|
|
259
260
|
case 12:
|
|
260
261
|
case "end":
|
|
@@ -318,7 +319,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
318
319
|
}, {
|
|
319
320
|
key: "proxy",
|
|
320
321
|
value: function proxy(parent) {
|
|
321
|
-
var
|
|
322
|
+
var _this4 = this;
|
|
322
323
|
|
|
323
324
|
ProxyFuncs.forEach(function (func) {
|
|
324
325
|
// @ts-ignore
|
|
@@ -331,14 +332,14 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
331
332
|
|
|
332
333
|
oldStyleFunc.apply(void 0, args);
|
|
333
334
|
|
|
334
|
-
|
|
335
|
+
_this4.getLayers().map(function (child) {
|
|
335
336
|
// @ts-ignore
|
|
336
337
|
child[func].apply(child, args);
|
|
337
338
|
}); // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
|
|
338
339
|
|
|
339
340
|
|
|
340
341
|
if (func === 'style') {
|
|
341
|
-
|
|
342
|
+
_this4.getTiles().forEach(function (tile) {
|
|
342
343
|
return tile.styleUpdate.apply(tile, args);
|
|
343
344
|
});
|
|
344
345
|
}
|
package/lib/core/BaseLayer.js
CHANGED
|
@@ -526,7 +526,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
526
526
|
key: "filter",
|
|
527
527
|
value: function filter(field, values, updateOptions) {
|
|
528
528
|
var flag = this.updateStyleAttribute('filter', field, values, updateOptions);
|
|
529
|
-
this.dataState.dataSourceNeedUpdate = flag;
|
|
529
|
+
this.dataState.dataSourceNeedUpdate = flag && this.inited;
|
|
530
530
|
return this;
|
|
531
531
|
}
|
|
532
532
|
}, {
|
|
@@ -537,7 +537,7 @@ var BaseLayer = (_dec = (0, _l7Core.lazyInject)(_l7Core.TYPES.IGlobalConfigServi
|
|
|
537
537
|
values: values
|
|
538
538
|
};
|
|
539
539
|
var flag = this.updateStyleAttribute('shape', field, values, updateOptions);
|
|
540
|
-
this.dataState.dataSourceNeedUpdate = flag;
|
|
540
|
+
this.dataState.dataSourceNeedUpdate = flag && this.inited;
|
|
541
541
|
return this;
|
|
542
542
|
}
|
|
543
543
|
}, {
|
|
@@ -7,14 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
11
|
|
|
14
12
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
15
13
|
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
14
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
19
15
|
|
|
20
16
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
@@ -32,6 +28,8 @@ var BaseLayerPickService = /*#__PURE__*/function () {
|
|
|
32
28
|
(0, _createClass2.default)(BaseLayerPickService, [{
|
|
33
29
|
key: "pickRender",
|
|
34
30
|
value: function pickRender(target) {
|
|
31
|
+
var container = this.layer.getContainer();
|
|
32
|
+
var layerService = container.get(_l7Core.TYPES.ILayerService);
|
|
35
33
|
var layer = this.layer; // 瓦片图层的拾取绘制
|
|
36
34
|
|
|
37
35
|
if (layer.tileLayer) {
|
|
@@ -39,35 +37,7 @@ var BaseLayerPickService = /*#__PURE__*/function () {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
layer.hooks.beforePickingEncode.call();
|
|
42
|
-
|
|
43
|
-
if (layer.masks.length > 0) {
|
|
44
|
-
// 若存在 mask,则在 pick 阶段的绘制也启用
|
|
45
|
-
layer.masks.filter(function (mask) {
|
|
46
|
-
return mask.inited;
|
|
47
|
-
}).forEach( /*#__PURE__*/function () {
|
|
48
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(m) {
|
|
49
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
50
|
-
while (1) {
|
|
51
|
-
switch (_context.prev = _context.next) {
|
|
52
|
-
case 0:
|
|
53
|
-
m.render({
|
|
54
|
-
isStencil: true
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
case 1:
|
|
58
|
-
case "end":
|
|
59
|
-
return _context.stop();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}, _callee);
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
return function (_x) {
|
|
66
|
-
return _ref.apply(this, arguments);
|
|
67
|
-
};
|
|
68
|
-
}());
|
|
69
|
-
}
|
|
70
|
-
|
|
40
|
+
layerService.renderTileLayerMask(layer);
|
|
71
41
|
layer.renderModels({
|
|
72
42
|
ispick: true
|
|
73
43
|
});
|
|
@@ -10,6 +10,8 @@ var _exportNames = {
|
|
|
10
10
|
};
|
|
11
11
|
exports.getTileFactory = getTileFactory;
|
|
12
12
|
|
|
13
|
+
var _l7Core = require("@antv/l7-core");
|
|
14
|
+
|
|
13
15
|
var _DebugTile = _interopRequireDefault(require("./DebugTile"));
|
|
14
16
|
|
|
15
17
|
var _ImageTile = _interopRequireDefault(require("./ImageTile"));
|
|
@@ -75,15 +77,16 @@ function getTileFactory(layer) {
|
|
|
75
77
|
var dataType = layer.getSource().parser.dataType;
|
|
76
78
|
|
|
77
79
|
switch (dataType) {
|
|
78
|
-
case
|
|
79
|
-
case
|
|
80
|
+
case _l7Core.RasterTileType.RGB:
|
|
81
|
+
case _l7Core.RasterTileType.CUSTOMRGB:
|
|
80
82
|
return _RasterRGBTile.default;
|
|
81
83
|
|
|
82
|
-
case
|
|
83
|
-
case
|
|
84
|
+
case _l7Core.RasterTileType.ARRAYBUFFER:
|
|
85
|
+
case _l7Core.RasterTileType.CUSTOMARRAYBUFFER:
|
|
84
86
|
return _RasterTile.default;
|
|
85
87
|
|
|
86
|
-
case
|
|
88
|
+
case _l7Core.RasterTileType.TERRAINRGB:
|
|
89
|
+
case _l7Core.RasterTileType.CUSTOMTERRAINRGB:
|
|
87
90
|
return _RasterTerrainRGBTile.default;
|
|
88
91
|
|
|
89
92
|
default:
|
|
@@ -32,8 +32,46 @@ var _tileFactory = require("../tileFactory");
|
|
|
32
32
|
var BaseTileLayer = /*#__PURE__*/function () {
|
|
33
33
|
// 瓦片数据管理器
|
|
34
34
|
function BaseTileLayer(parent) {
|
|
35
|
+
var _this = this;
|
|
36
|
+
|
|
35
37
|
(0, _classCallCheck2.default)(this, BaseTileLayer);
|
|
36
38
|
(0, _defineProperty2.default)(this, "initedTileset", false);
|
|
39
|
+
(0, _defineProperty2.default)(this, "mapchange", function () {
|
|
40
|
+
var _this$tilesetManager;
|
|
41
|
+
|
|
42
|
+
var _this$getCurrentView = _this.getCurrentView(),
|
|
43
|
+
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
44
|
+
zoom = _this$getCurrentView.zoom;
|
|
45
|
+
|
|
46
|
+
if (_this.mapService.version === 'GAODE1.x') {
|
|
47
|
+
var _this$parent$getLayer = _this.parent.getLayerConfig(),
|
|
48
|
+
visible = _this$parent$getLayer.visible;
|
|
49
|
+
|
|
50
|
+
if (zoom < 2 && visible) {
|
|
51
|
+
_this.parent.updateLayerConfig({
|
|
52
|
+
visible: false
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
_this.layerService.reRender();
|
|
56
|
+
} else if (zoom >= 2 && !visible) {
|
|
57
|
+
_this.parent.updateLayerConfig({
|
|
58
|
+
visible: true
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
_this.layerService.reRender();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (_this.lastViewStates && _this.lastViewStates.zoom === zoom && _this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_this.lastViewStates = {
|
|
70
|
+
zoom: zoom,
|
|
71
|
+
latLonBounds: latLonBounds
|
|
72
|
+
};
|
|
73
|
+
(_this$tilesetManager = _this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.throttleUpdate(zoom, latLonBounds);
|
|
74
|
+
});
|
|
37
75
|
(0, _defineProperty2.default)(this, "viewchange", (0, _lodash.debounce)(this.mapchange, 24));
|
|
38
76
|
this.parent = parent;
|
|
39
77
|
var container = this.parent.getContainer();
|
|
@@ -62,7 +100,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
62
100
|
(0, _createClass2.default)(BaseTileLayer, [{
|
|
63
101
|
key: "initTileSetManager",
|
|
64
102
|
value: function initTileSetManager() {
|
|
65
|
-
var _this$
|
|
103
|
+
var _this$tilesetManager2;
|
|
66
104
|
|
|
67
105
|
var source = this.parent.getSource();
|
|
68
106
|
this.tilesetManager = source.tileset;
|
|
@@ -72,47 +110,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
72
110
|
this.initedTileset = true;
|
|
73
111
|
}
|
|
74
112
|
|
|
75
|
-
var _this$getCurrentView = this.getCurrentView(),
|
|
76
|
-
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
77
|
-
zoom = _this$getCurrentView.zoom;
|
|
78
|
-
|
|
79
|
-
(_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
|
|
80
|
-
}
|
|
81
|
-
}, {
|
|
82
|
-
key: "mapchange",
|
|
83
|
-
value: function mapchange() {
|
|
84
|
-
var _this$tilesetManager2;
|
|
85
|
-
|
|
86
113
|
var _this$getCurrentView2 = this.getCurrentView(),
|
|
87
114
|
latLonBounds = _this$getCurrentView2.latLonBounds,
|
|
88
115
|
zoom = _this$getCurrentView2.zoom;
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
var _this$parent$getLayer = this.parent.getLayerConfig(),
|
|
92
|
-
visible = _this$parent$getLayer.visible;
|
|
93
|
-
|
|
94
|
-
if (zoom < 2 && visible) {
|
|
95
|
-
this.parent.updateLayerConfig({
|
|
96
|
-
visible: false
|
|
97
|
-
});
|
|
98
|
-
this.layerService.reRender();
|
|
99
|
-
} else if (zoom >= 2 && !visible) {
|
|
100
|
-
this.parent.updateLayerConfig({
|
|
101
|
-
visible: true
|
|
102
|
-
});
|
|
103
|
-
this.layerService.reRender();
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
this.lastViewStates = {
|
|
112
|
-
zoom: zoom,
|
|
113
|
-
latLonBounds: latLonBounds
|
|
114
|
-
};
|
|
115
|
-
(_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.throttleUpdate(zoom, latLonBounds);
|
|
117
|
+
(_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds);
|
|
116
118
|
}
|
|
117
119
|
}, {
|
|
118
120
|
key: "getCurrentView",
|
|
@@ -128,7 +130,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
128
130
|
}, {
|
|
129
131
|
key: "bindTilesetEvent",
|
|
130
132
|
value: function bindTilesetEvent() {
|
|
131
|
-
var
|
|
133
|
+
var _this2 = this;
|
|
132
134
|
|
|
133
135
|
// 瓦片数据加载成功
|
|
134
136
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -137,25 +139,21 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
137
139
|
|
|
138
140
|
this.tilesetManager.on('tile-unload', function (tile) {
|
|
139
141
|
// 将事件抛出,图层上可以监听使用
|
|
140
|
-
|
|
142
|
+
_this2.tileUnLoad(tile);
|
|
141
143
|
}); // 瓦片数据加载失败
|
|
142
144
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
143
145
|
|
|
144
146
|
this.tilesetManager.on('tile-error', function (error, tile) {
|
|
145
147
|
// 将事件抛出,图层上可以监听使用
|
|
146
|
-
|
|
148
|
+
_this2.tileError(error);
|
|
147
149
|
}); // 瓦片显隐状态更新
|
|
148
150
|
|
|
149
151
|
this.tilesetManager.on('tile-update', function () {
|
|
150
|
-
|
|
152
|
+
_this2.tileUpdate();
|
|
151
153
|
}); // 地图视野发生改变
|
|
152
154
|
|
|
153
|
-
this.mapService.on('zoomend',
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
this.mapService.on('moveend', function () {
|
|
157
|
-
return _this.viewchange();
|
|
158
|
-
});
|
|
155
|
+
this.mapService.on('zoomend', this.mapchange);
|
|
156
|
+
this.mapService.on('moveend', this.viewchange);
|
|
159
157
|
}
|
|
160
158
|
}, {
|
|
161
159
|
key: "render",
|
|
@@ -193,6 +191,8 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
193
191
|
value: function destroy() {
|
|
194
192
|
var _this$tilesetManager3;
|
|
195
193
|
|
|
194
|
+
this.mapService.off('zoomend', this.mapchange);
|
|
195
|
+
this.mapService.off('moveend', this.viewchange);
|
|
196
196
|
(_this$tilesetManager3 = this.tilesetManager) === null || _this$tilesetManager3 === void 0 ? void 0 : _this$tilesetManager3.destroy();
|
|
197
197
|
this.tileLayerService.destroy();
|
|
198
198
|
}
|
|
@@ -205,7 +205,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
205
205
|
key: "tileUpdate",
|
|
206
206
|
value: function () {
|
|
207
207
|
var _tileUpdate = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
208
|
-
var
|
|
208
|
+
var _this3 = this;
|
|
209
209
|
|
|
210
210
|
var minZoom, maxZoom;
|
|
211
211
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
@@ -240,25 +240,25 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
240
240
|
while (1) {
|
|
241
241
|
switch (_context.prev = _context.next) {
|
|
242
242
|
case 0:
|
|
243
|
-
if (
|
|
243
|
+
if (_this3.tileLayerService.hasTile(tile.key)) {
|
|
244
244
|
_context.next = 9;
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
247
|
|
|
248
|
-
tileInstance = (0, _tileFactory.getTileFactory)(
|
|
249
|
-
tileLayer = new tileInstance(tile,
|
|
248
|
+
tileInstance = (0, _tileFactory.getTileFactory)(_this3.parent);
|
|
249
|
+
tileLayer = new tileInstance(tile, _this3.parent);
|
|
250
250
|
_context.next = 5;
|
|
251
251
|
return tileLayer.initTileLayer();
|
|
252
252
|
|
|
253
253
|
case 5:
|
|
254
|
-
|
|
254
|
+
_this3.tilePickService.setPickState();
|
|
255
255
|
|
|
256
256
|
if (tileLayer.getLayers().length !== 0) {
|
|
257
|
-
|
|
257
|
+
_this3.tileLayerService.addTile(tileLayer);
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
_this3.tileLayerService.updateTileVisible(tile);
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
_this3.layerService.reRender();
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
_context.next = 12;
|
|
@@ -266,11 +266,11 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
266
266
|
|
|
267
267
|
case 9:
|
|
268
268
|
// 已加载瓦片
|
|
269
|
-
|
|
269
|
+
_this3.tileLayerService.updateTileVisible(tile);
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
_this3.tilePickService.setPickState();
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
_this3.layerService.reRender();
|
|
274
274
|
|
|
275
275
|
case 12:
|
|
276
276
|
case "end":
|
|
@@ -334,7 +334,7 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
334
334
|
}, {
|
|
335
335
|
key: "proxy",
|
|
336
336
|
value: function proxy(parent) {
|
|
337
|
-
var
|
|
337
|
+
var _this4 = this;
|
|
338
338
|
|
|
339
339
|
_constants.ProxyFuncs.forEach(function (func) {
|
|
340
340
|
// @ts-ignore
|
|
@@ -347,14 +347,14 @@ var BaseTileLayer = /*#__PURE__*/function () {
|
|
|
347
347
|
|
|
348
348
|
oldStyleFunc.apply(void 0, args);
|
|
349
349
|
|
|
350
|
-
|
|
350
|
+
_this4.getLayers().map(function (child) {
|
|
351
351
|
// @ts-ignore
|
|
352
352
|
child[func].apply(child, args);
|
|
353
353
|
}); // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
|
|
354
354
|
|
|
355
355
|
|
|
356
356
|
if (func === 'style') {
|
|
357
|
-
|
|
357
|
+
_this4.getTiles().forEach(function (tile) {
|
|
358
358
|
return tile.styleUpdate.apply(tile, args);
|
|
359
359
|
});
|
|
360
360
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.14.
|
|
3
|
+
"version": "2.14.4",
|
|
4
4
|
"description": "L7's collection of built-in layers",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@antv/async-hook": "^2.2.9",
|
|
30
|
-
"@antv/l7-core": "2.14.
|
|
31
|
-
"@antv/l7-maps": "2.14.
|
|
32
|
-
"@antv/l7-source": "2.14.
|
|
33
|
-
"@antv/l7-utils": "2.14.
|
|
30
|
+
"@antv/l7-core": "2.14.4",
|
|
31
|
+
"@antv/l7-maps": "2.14.4",
|
|
32
|
+
"@antv/l7-source": "2.14.4",
|
|
33
|
+
"@antv/l7-utils": "2.14.4",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"reflect-metadata": "^0.1.13"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@antv/l7-test-utils": "2.14.
|
|
56
|
+
"@antv/l7-test-utils": "2.14.4",
|
|
57
57
|
"@types/d3-array": "^2.0.0",
|
|
58
58
|
"@types/d3-color": "^1.2.2",
|
|
59
59
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@types/gl-matrix": "^2.4.5",
|
|
63
63
|
"@types/lodash": "^4.14.138"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "0d01c2e1daea1b571b4e467186c9fee754b98429",
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
68
68
|
}
|