@antv/l7-layers 2.19.3 → 2.19.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/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/line/models/simpleLine.js +2 -2
- package/es/line/shaders/simple/simpleline_linear_frag.glsl +3 -2
- package/es/line/shaders/simple/simpleline_vert.glsl +0 -2
- package/es/plugins/LayerModelPlugin.js +1 -1
- package/es/plugins/RegisterStyleAttributePlugin.js +1 -1
- package/es/polygon/models/fill.js +12 -18
- package/es/tile/{tileLayer → core}/BaseLayer.js +6 -5
- package/es/tile/{tileFactory/layers → core}/TileDebugLayer.d.ts +2 -2
- package/es/tile/{tileFactory/layers → core}/TileDebugLayer.js +1 -1
- package/es/tile/service/TileLayerService.js +22 -26
- package/es/tile/{tileFactory → tile}/Tile.d.ts +3 -1
- package/es/tile/{tileFactory → tile}/Tile.js +29 -15
- package/es/tile/{tileFactory → tile}/VectorTile.js +10 -8
- package/lib/index.js +1 -1
- package/lib/line/models/simpleLine.js +2 -2
- package/lib/line/shaders/simple/simpleline_linear_frag.glsl +3 -2
- package/lib/line/shaders/simple/simpleline_vert.glsl +0 -2
- package/lib/plugins/LayerModelPlugin.js +1 -1
- package/lib/plugins/RegisterStyleAttributePlugin.js +1 -1
- package/lib/polygon/models/fill.js +12 -18
- package/lib/tile/{tileLayer → core}/BaseLayer.js +7 -6
- package/lib/tile/{tileFactory/layers → core}/TileDebugLayer.js +1 -1
- package/lib/tile/service/TileLayerService.js +22 -26
- package/lib/tile/{tileFactory → tile}/Tile.js +29 -15
- package/lib/tile/{tileFactory → tile}/VectorTile.js +10 -8
- package/package.json +7 -7
- package/es/tile/manager/base.d.ts +0 -35
- package/es/tile/manager/base.js +0 -290
- package/es/tile/style/utils.d.ts +0 -2
- package/es/tile/style/utils.js +0 -13
- package/lib/tile/manager/base.js +0 -298
- package/lib/tile/style/utils.js +0 -20
- /package/es/tile/{tileLayer → core}/BaseLayer.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/DebugTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/DebugTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/ImageTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/ImageTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/MaskTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/MaskTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/RasterRGBTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/RasterRGBTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/RasterTerrainRGBTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/RasterTerrainRGBTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/RasterTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/RasterTile.js +0 -0
- /package/es/tile/{tileFactory → tile}/VectorTile.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/index.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/index.js +0 -0
- /package/es/tile/{tileFactory → tile}/util.d.ts +0 -0
- /package/es/tile/{tileFactory → tile}/util.js +0 -0
- /package/es/tile/{style → utils}/constants.d.ts +0 -0
- /package/es/tile/{style → utils}/constants.js +0 -0
- /package/es/tile/{utils.d.ts → utils/utils.d.ts} +0 -0
- /package/es/tile/{utils.js → utils/utils.js} +0 -0
- /package/lib/tile/{tileFactory → tile}/DebugTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/ImageTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/MaskTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/RasterRGBTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/RasterTerrainRGBTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/RasterTile.js +0 -0
- /package/lib/tile/{tileFactory → tile}/index.js +0 -0
- /package/lib/tile/{tileFactory → tile}/util.js +0 -0
- /package/lib/tile/{style → utils}/constants.js +0 -0
- /package/lib/tile/{utils.js → utils/utils.js} +0 -0
|
@@ -74,30 +74,23 @@ var TileLayerService = /*#__PURE__*/function () {
|
|
|
74
74
|
key: "updateTileVisible",
|
|
75
75
|
value: function updateTileVisible(sourceTile) {
|
|
76
76
|
var tile = this.getTile(sourceTile.key);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
// }
|
|
95
|
-
tile === null || tile === void 0 ? void 0 : tile.updateVisible(sourceTile.isVisible);
|
|
96
|
-
// if (sourceTile.isVisible) {
|
|
97
|
-
// tile?.updateVisible(sourceTile.isVisible);
|
|
98
|
-
// } else {
|
|
99
|
-
// this.removeTile(sourceTile.key);
|
|
100
|
-
// }
|
|
77
|
+
if (sourceTile.isVisible) {
|
|
78
|
+
// 不可见 => 可见 兄弟节点加载完成
|
|
79
|
+
if (sourceTile.parent) {
|
|
80
|
+
var flag = this.isChildrenLoaded(sourceTile.parent);
|
|
81
|
+
tile === null || tile === void 0 ? void 0 : tile.updateVisible(flag);
|
|
82
|
+
} else {
|
|
83
|
+
tile === null || tile === void 0 ? void 0 : tile.updateVisible(true);
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
// 可见 => 不可见 兄弟节点加载完成
|
|
87
|
+
if (sourceTile.parent) {
|
|
88
|
+
var _flag = this.isChildrenLoaded(sourceTile.parent);
|
|
89
|
+
tile === null || tile === void 0 ? void 0 : tile.updateVisible(!_flag);
|
|
90
|
+
} else {
|
|
91
|
+
tile === null || tile === void 0 ? void 0 : tile.updateVisible(false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
101
94
|
}
|
|
102
95
|
}, {
|
|
103
96
|
key: "isParentLoaded",
|
|
@@ -121,9 +114,12 @@ var TileLayerService = /*#__PURE__*/function () {
|
|
|
121
114
|
if (childrenTile.length === 0) {
|
|
122
115
|
return true;
|
|
123
116
|
}
|
|
124
|
-
return childrenTile.
|
|
117
|
+
return childrenTile.every(function (tile) {
|
|
125
118
|
var tileLayer = _this.getTile(tile === null || tile === void 0 ? void 0 : tile.key);
|
|
126
|
-
|
|
119
|
+
if (!tileLayer) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return (tileLayer === null || tileLayer === void 0 ? void 0 : tileLayer.isLoaded) === true;
|
|
127
123
|
});
|
|
128
124
|
}
|
|
129
125
|
}, {
|
|
@@ -11,23 +11,35 @@ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
11
11
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
12
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
13
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
18
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
19
|
var _l7Core = require("@antv/l7-core");
|
|
20
|
+
var _eventemitter = require("eventemitter3");
|
|
16
21
|
var _polygon = _interopRequireDefault(require("../../polygon"));
|
|
17
22
|
var _util = require("./util");
|
|
18
|
-
var
|
|
23
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
24
|
+
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; } }
|
|
25
|
+
var Tile = /*#__PURE__*/function (_EventEmitter) {
|
|
26
|
+
(0, _inherits2.default)(Tile, _EventEmitter);
|
|
27
|
+
var _super = _createSuper(Tile);
|
|
19
28
|
function Tile(sourceTile, parent) {
|
|
29
|
+
var _this;
|
|
20
30
|
(0, _classCallCheck2.default)(this, Tile);
|
|
21
|
-
|
|
22
|
-
(0, _defineProperty2.default)(
|
|
23
|
-
(0, _defineProperty2.default)(
|
|
24
|
-
(0, _defineProperty2.default)(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
_this = _super.call(this);
|
|
32
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "visible", true);
|
|
33
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "layers", []);
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isLoaded", false);
|
|
35
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tileMaskLayers", []);
|
|
36
|
+
_this.parent = parent;
|
|
37
|
+
_this.sourceTile = sourceTile;
|
|
38
|
+
_this.x = sourceTile.x;
|
|
39
|
+
_this.y = sourceTile.y;
|
|
40
|
+
_this.z = sourceTile.z;
|
|
41
|
+
_this.key = "".concat(_this.x, "_").concat(_this.y, "_").concat(_this.z);
|
|
42
|
+
return _this;
|
|
31
43
|
}
|
|
32
44
|
(0, _createClass2.default)(Tile, [{
|
|
33
45
|
key: "getLayers",
|
|
@@ -71,7 +83,7 @@ var Tile = /*#__PURE__*/function () {
|
|
|
71
83
|
}, {
|
|
72
84
|
key: "getMaskLayer",
|
|
73
85
|
value: function getMaskLayer() {
|
|
74
|
-
var
|
|
86
|
+
var _this2 = this;
|
|
75
87
|
var _this$parent$getLayer = this.parent.getLayerConfig(),
|
|
76
88
|
maskLayers = _this$parent$getLayer.maskLayers;
|
|
77
89
|
var layers = [];
|
|
@@ -82,7 +94,7 @@ var Tile = /*#__PURE__*/function () {
|
|
|
82
94
|
return layer;
|
|
83
95
|
}
|
|
84
96
|
var tileLayer = layer.tileLayer;
|
|
85
|
-
var tile = tileLayer.getTile(
|
|
97
|
+
var tile = tileLayer.getTile(_this2.sourceTile.key);
|
|
86
98
|
var l = tile === null || tile === void 0 ? void 0 : tile.getLayers()[0];
|
|
87
99
|
if (l) {
|
|
88
100
|
layers.push(l);
|
|
@@ -109,7 +121,9 @@ var Tile = /*#__PURE__*/function () {
|
|
|
109
121
|
type: 'geojson',
|
|
110
122
|
featureId: 'id'
|
|
111
123
|
}
|
|
112
|
-
}).shape('fill')
|
|
124
|
+
}).shape('fill').style({
|
|
125
|
+
opacity: 0.5
|
|
126
|
+
});
|
|
113
127
|
container = (0, _l7Core.createLayerContainer)(this.parent.sceneContainer);
|
|
114
128
|
mask.setContainer(container, this.parent.sceneContainer);
|
|
115
129
|
_context.next = 5;
|
|
@@ -233,5 +247,5 @@ var Tile = /*#__PURE__*/function () {
|
|
|
233
247
|
}
|
|
234
248
|
}]);
|
|
235
249
|
return Tile;
|
|
236
|
-
}();
|
|
250
|
+
}(_eventemitter.EventEmitter);
|
|
237
251
|
exports.default = Tile;
|
|
@@ -37,12 +37,13 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
|
|
|
37
37
|
vectorLayer = (0, _util.getTileLayer)(this.parent.type);
|
|
38
38
|
sourceOptions = this.getSourceOption();
|
|
39
39
|
if (sourceOptions) {
|
|
40
|
-
_context.next =
|
|
40
|
+
_context.next = 8;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
43
|
this.isLoaded = true;
|
|
44
|
+
this.emit('loaded');
|
|
44
45
|
return _context.abrupt("return");
|
|
45
|
-
case
|
|
46
|
+
case 8:
|
|
46
47
|
layer = new vectorLayer((0, _objectSpread2.default)({}, layerOptions)).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
|
|
47
48
|
Object.keys(attributes).forEach(function (type) {
|
|
48
49
|
var _attributes$attr, _attributes$attr2;
|
|
@@ -50,19 +51,20 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
|
|
|
50
51
|
// @ts-ignore
|
|
51
52
|
layer[attr]((_attributes$attr = attributes[attr]) === null || _attributes$attr === void 0 ? void 0 : _attributes$attr.field, (_attributes$attr2 = attributes[attr]) === null || _attributes$attr2 === void 0 ? void 0 : _attributes$attr2.values);
|
|
52
53
|
});
|
|
53
|
-
_context.next =
|
|
54
|
+
_context.next = 12;
|
|
54
55
|
return this.addLayer(layer);
|
|
55
|
-
case
|
|
56
|
+
case 12:
|
|
56
57
|
if (!layerOptions.tileMask) {
|
|
57
|
-
_context.next =
|
|
58
|
+
_context.next = 15;
|
|
58
59
|
break;
|
|
59
60
|
}
|
|
60
|
-
_context.next =
|
|
61
|
+
_context.next = 15;
|
|
61
62
|
return this.addTileMask();
|
|
62
|
-
case
|
|
63
|
+
case 15:
|
|
63
64
|
this.setLayerMinMaxZoom(layer);
|
|
64
65
|
this.isLoaded = true;
|
|
65
|
-
|
|
66
|
+
this.emit('loaded');
|
|
67
|
+
case 18:
|
|
66
68
|
case "end":
|
|
67
69
|
return _context.stop();
|
|
68
70
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-layers",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.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.19.
|
|
31
|
-
"@antv/l7-maps": "2.19.
|
|
32
|
-
"@antv/l7-source": "2.19.
|
|
33
|
-
"@antv/l7-utils": "2.19.
|
|
30
|
+
"@antv/l7-core": "2.19.4",
|
|
31
|
+
"@antv/l7-maps": "2.19.4",
|
|
32
|
+
"@antv/l7-source": "2.19.4",
|
|
33
|
+
"@antv/l7-utils": "2.19.4",
|
|
34
34
|
"@babel/runtime": "^7.7.7",
|
|
35
35
|
"@mapbox/martini": "^0.2.0",
|
|
36
36
|
"@turf/clone": "^6.5.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"reflect-metadata": "^0.1.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@antv/l7-test-utils": "2.19.
|
|
55
|
+
"@antv/l7-test-utils": "2.19.4",
|
|
56
56
|
"@types/d3-array": "^2.0.0",
|
|
57
57
|
"@types/d3-color": "^1.2.2",
|
|
58
58
|
"@types/d3-interpolate": "1.1.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@types/gl-matrix": "^2.4.5",
|
|
62
62
|
"@types/lodash": "^4.14.138"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "6cfa2a8906a86d9e8c62ed4a2e17ba607009f34a",
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ILayer, ILayerService, IMapService, IRendererService, ISubLayerInitOptions } from '@antv/l7-core';
|
|
2
|
-
import { SourceTile } from '@antv/l7-utils';
|
|
3
|
-
export declare class Base {
|
|
4
|
-
sourceLayer: string;
|
|
5
|
-
parent: ILayer;
|
|
6
|
-
children: ILayer[];
|
|
7
|
-
mapService: IMapService;
|
|
8
|
-
rendererService: IRendererService;
|
|
9
|
-
protected tileFactory: any;
|
|
10
|
-
protected initOptions: ISubLayerInitOptions;
|
|
11
|
-
private tileCache;
|
|
12
|
-
private tileLayerCache;
|
|
13
|
-
private initTileLayers;
|
|
14
|
-
render(): void;
|
|
15
|
-
hasTile(tile: SourceTile): boolean;
|
|
16
|
-
addTile(tile: SourceTile): Promise<any>;
|
|
17
|
-
removeTile(tile: SourceTile): void;
|
|
18
|
-
addChild(layer: ILayer): void;
|
|
19
|
-
addChildren(layers: ILayer[]): void;
|
|
20
|
-
removeLayers(layers?: ILayer[], refresh?: boolean): void;
|
|
21
|
-
removeChild(layer: ILayer): void;
|
|
22
|
-
getLayers(tile: SourceTile): ILayer[];
|
|
23
|
-
getChild(layerID: string): ILayer;
|
|
24
|
-
clearChild(): void;
|
|
25
|
-
hasChild(layer: ILayer): boolean;
|
|
26
|
-
initTileFactory(): void;
|
|
27
|
-
getSourceLayer(parentParserType: string, sourceLayer: string | undefined): string | undefined;
|
|
28
|
-
updateTileVisible(tile: SourceTile, layerService: ILayerService): void;
|
|
29
|
-
listenLoad(tile: SourceTile, callback: () => void): void;
|
|
30
|
-
isTileLoaded(tile: SourceTile): boolean;
|
|
31
|
-
isTileChildLoaded(tile: SourceTile): boolean;
|
|
32
|
-
isTileParentLoaded(tile: SourceTile): boolean;
|
|
33
|
-
isTileAllLoad(tile: SourceTile): boolean;
|
|
34
|
-
destroy(): void;
|
|
35
|
-
}
|
package/es/tile/manager/base.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
3
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
4
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
5
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
6
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
-
import { createLayerContainer } from '@antv/l7-core';
|
|
8
|
-
import { updateLayersConfig } from "../style/utils";
|
|
9
|
-
export var Base = /*#__PURE__*/function () {
|
|
10
|
-
function Base() {
|
|
11
|
-
_classCallCheck(this, Base);
|
|
12
|
-
_defineProperty(this, "tileCache", new Map());
|
|
13
|
-
_defineProperty(this, "tileLayerCache", new Map());
|
|
14
|
-
}
|
|
15
|
-
_createClass(Base, [{
|
|
16
|
-
key: "initTileLayers",
|
|
17
|
-
value: function () {
|
|
18
|
-
var _initTileLayers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layers, tile) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
21
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
22
|
-
case 0:
|
|
23
|
-
return _context2.abrupt("return", Promise.all(layers.map( /*#__PURE__*/function () {
|
|
24
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
|
|
25
|
-
var container;
|
|
26
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
27
|
-
while (1) switch (_context.prev = _context.next) {
|
|
28
|
-
case 0:
|
|
29
|
-
container = createLayerContainer(_this.parent.sceneContainer);
|
|
30
|
-
layer.setContainer(container, _this.parent.sceneContainer);
|
|
31
|
-
_context.next = 4;
|
|
32
|
-
return layer.init();
|
|
33
|
-
case 4:
|
|
34
|
-
_this.addChild(layer);
|
|
35
|
-
tile.layerLoad();
|
|
36
|
-
_this.render();
|
|
37
|
-
case 7:
|
|
38
|
-
case "end":
|
|
39
|
-
return _context.stop();
|
|
40
|
-
}
|
|
41
|
-
}, _callee);
|
|
42
|
-
}));
|
|
43
|
-
return function (_x3) {
|
|
44
|
-
return _ref.apply(this, arguments);
|
|
45
|
-
};
|
|
46
|
-
}())));
|
|
47
|
-
case 1:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context2.stop();
|
|
50
|
-
}
|
|
51
|
-
}, _callee2);
|
|
52
|
-
}));
|
|
53
|
-
function initTileLayers(_x, _x2) {
|
|
54
|
-
return _initTileLayers.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
return initTileLayers;
|
|
57
|
-
}()
|
|
58
|
-
}, {
|
|
59
|
-
key: "render",
|
|
60
|
-
value: function render() {
|
|
61
|
-
this.parent.renderLayers();
|
|
62
|
-
}
|
|
63
|
-
}, {
|
|
64
|
-
key: "hasTile",
|
|
65
|
-
value: function hasTile(tile) {
|
|
66
|
-
return this.tileCache.has(tile.key);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// 添加图层
|
|
70
|
-
}, {
|
|
71
|
-
key: "addTile",
|
|
72
|
-
value: function () {
|
|
73
|
-
var _addTile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tile) {
|
|
74
|
-
var layerCollections;
|
|
75
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
76
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
77
|
-
case 0:
|
|
78
|
-
if (!this.hasTile(tile)) {
|
|
79
|
-
_context3.next = 2;
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
return _context3.abrupt("return", {
|
|
83
|
-
layers: []
|
|
84
|
-
});
|
|
85
|
-
case 2:
|
|
86
|
-
// 存储当前 tile
|
|
87
|
-
this.tileCache.set(tile.key, tile);
|
|
88
|
-
|
|
89
|
-
// 创建 tile 对应的 layers
|
|
90
|
-
layerCollections = this.tileFactory.createTile(tile, this.initOptions); // // 初始化图层
|
|
91
|
-
_context3.next = 6;
|
|
92
|
-
return this.initTileLayers(layerCollections.layers, tile);
|
|
93
|
-
case 6:
|
|
94
|
-
this.tileLayerCache.set(tile.key, layerCollections.layers);
|
|
95
|
-
// const visible = tile.parent ? tile.parent.children.every(t=>this.tileLayerCache.has(t.key)) : true
|
|
96
|
-
// tile.parent?.children.forEach((t)=>{
|
|
97
|
-
// updateLayersConfig(this.getLayers(t),'visible',visible)
|
|
98
|
-
// })
|
|
99
|
-
return _context3.abrupt("return", layerCollections);
|
|
100
|
-
case 8:
|
|
101
|
-
case "end":
|
|
102
|
-
return _context3.stop();
|
|
103
|
-
}
|
|
104
|
-
}, _callee3, this);
|
|
105
|
-
}));
|
|
106
|
-
function addTile(_x4) {
|
|
107
|
-
return _addTile.apply(this, arguments);
|
|
108
|
-
}
|
|
109
|
-
return addTile;
|
|
110
|
-
}()
|
|
111
|
-
}, {
|
|
112
|
-
key: "removeTile",
|
|
113
|
-
value: function removeTile(tile) {
|
|
114
|
-
this.tileCache.delete(tile.key);
|
|
115
|
-
var layers = this.tileLayerCache.get(tile.key);
|
|
116
|
-
this.tileLayerCache.delete(tile.key);
|
|
117
|
-
this.removeLayers(layers, false);
|
|
118
|
-
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "addChild",
|
|
121
|
-
value: function addChild(layer) {
|
|
122
|
-
this.children.push(layer);
|
|
123
|
-
}
|
|
124
|
-
}, {
|
|
125
|
-
key: "addChildren",
|
|
126
|
-
value: function addChildren(layers) {
|
|
127
|
-
var _this$children;
|
|
128
|
-
(_this$children = this.children).push.apply(_this$children, _toConsumableArray(layers));
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "removeLayers",
|
|
132
|
-
value: function removeLayers() {
|
|
133
|
-
var layers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
134
|
-
var refresh = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
135
|
-
this.children = this.children.filter(function (child) {
|
|
136
|
-
return !layers.includes(child);
|
|
137
|
-
});
|
|
138
|
-
layers.map(function (layer) {
|
|
139
|
-
return layer.destroy(refresh);
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
key: "removeChild",
|
|
144
|
-
value: function removeChild(layer) {
|
|
145
|
-
var layerIndex = this.children.indexOf(layer);
|
|
146
|
-
if (layerIndex > -1) {
|
|
147
|
-
this.children.splice(layerIndex, 1);
|
|
148
|
-
}
|
|
149
|
-
layer.destroy();
|
|
150
|
-
}
|
|
151
|
-
}, {
|
|
152
|
-
key: "getLayers",
|
|
153
|
-
value: function getLayers(tile) {
|
|
154
|
-
if (!tile) {
|
|
155
|
-
return [];
|
|
156
|
-
}
|
|
157
|
-
return this.tileLayerCache.get(tile.key) || [];
|
|
158
|
-
}
|
|
159
|
-
}, {
|
|
160
|
-
key: "getChild",
|
|
161
|
-
value: function getChild(layerID) {
|
|
162
|
-
return this.children.filter(function (child) {
|
|
163
|
-
return child.id === layerID;
|
|
164
|
-
})[0];
|
|
165
|
-
}
|
|
166
|
-
}, {
|
|
167
|
-
key: "clearChild",
|
|
168
|
-
value: function clearChild() {
|
|
169
|
-
this.children.forEach(function (layer) {
|
|
170
|
-
layer.destroy();
|
|
171
|
-
});
|
|
172
|
-
this.children.slice(0, this.children.length);
|
|
173
|
-
}
|
|
174
|
-
}, {
|
|
175
|
-
key: "hasChild",
|
|
176
|
-
value: function hasChild(layer) {
|
|
177
|
-
return this.children.includes(layer);
|
|
178
|
-
}
|
|
179
|
-
}, {
|
|
180
|
-
key: "initTileFactory",
|
|
181
|
-
value: function initTileFactory() {
|
|
182
|
-
// this.tileFactory = new TileFactory({
|
|
183
|
-
// parent: this.parent,
|
|
184
|
-
// mapService: this.mapService,
|
|
185
|
-
// rendererService: this.rendererService,
|
|
186
|
-
// });
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "getSourceLayer",
|
|
190
|
-
value: function getSourceLayer(parentParserType, sourceLayer) {
|
|
191
|
-
if (parentParserType === 'geojsonvt') {
|
|
192
|
-
return 'geojsonvt';
|
|
193
|
-
} else if (parentParserType === 'testTile') {
|
|
194
|
-
return 'testTile';
|
|
195
|
-
} else {
|
|
196
|
-
return sourceLayer;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}, {
|
|
200
|
-
key: "updateTileVisible",
|
|
201
|
-
value: function updateTileVisible(tile, layerService) {
|
|
202
|
-
var layers = this.getLayers(tile);
|
|
203
|
-
if (layers.length === 0) {
|
|
204
|
-
return;
|
|
205
|
-
}
|
|
206
|
-
if (tile.isVisible) {
|
|
207
|
-
// 如果可见直接进行渲染,父级发
|
|
208
|
-
updateLayersConfig(layers, 'visible', tile.isVisible);
|
|
209
|
-
} else {
|
|
210
|
-
// 如果不可见,放大,等到子瓦片渲染完成,缩小:父级渲染成功
|
|
211
|
-
// console.log('updateTileVisible',`${tile.x}_${tile.y}_${tile.z}`,tile.isVisible)
|
|
212
|
-
// console.log(tile);
|
|
213
|
-
// console.log(`子瓦片${tile.x}/${tile.y}/${tile.z}`,tile.children.length)
|
|
214
|
-
// tile.children.forEach((t)=>{
|
|
215
|
-
// console.log(`${t.x}/${t.y}/${t.z}`)
|
|
216
|
-
// })
|
|
217
|
-
updateLayersConfig(layers, 'visible', tile.isVisible);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// this.listenLoad(tile, () => {
|
|
221
|
-
// this.isTileAllLoad(tile) && updateLayersConfig(layers, 'visible', tile.isVisible);
|
|
222
|
-
// })
|
|
223
|
-
}
|
|
224
|
-
}, {
|
|
225
|
-
key: "listenLoad",
|
|
226
|
-
value: function listenLoad(tile, callback) {
|
|
227
|
-
var _tile$parent;
|
|
228
|
-
tile.once('layerLoaded', function () {
|
|
229
|
-
callback();
|
|
230
|
-
});
|
|
231
|
-
tile.children.map(function (childTile) {
|
|
232
|
-
childTile.once('layerLoaded', function () {
|
|
233
|
-
callback();
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
(_tile$parent = tile.parent) === null || _tile$parent === void 0 ? void 0 : _tile$parent.once('layerLoaded', function () {
|
|
237
|
-
callback();
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
}, {
|
|
241
|
-
key: "isTileLoaded",
|
|
242
|
-
value: function isTileLoaded(tile) {
|
|
243
|
-
if (tile.isLoad) {
|
|
244
|
-
return true;
|
|
245
|
-
}
|
|
246
|
-
var isLoad = this.getLayers(tile).length === tile.loadedLayers;
|
|
247
|
-
tile.isLoad = isLoad;
|
|
248
|
-
return isLoad;
|
|
249
|
-
}
|
|
250
|
-
}, {
|
|
251
|
-
key: "isTileChildLoaded",
|
|
252
|
-
value: function isTileChildLoaded(tile) {
|
|
253
|
-
var _this2 = this;
|
|
254
|
-
if (tile.isChildLoad) {
|
|
255
|
-
return true;
|
|
256
|
-
}
|
|
257
|
-
var children = tile.children;
|
|
258
|
-
var isLoad = children.filter(function (child) {
|
|
259
|
-
return _this2.isTileLoaded(child);
|
|
260
|
-
}).length === children.length;
|
|
261
|
-
tile.isChildLoad = isLoad;
|
|
262
|
-
return isLoad;
|
|
263
|
-
}
|
|
264
|
-
}, {
|
|
265
|
-
key: "isTileParentLoaded",
|
|
266
|
-
value: function isTileParentLoaded(tile) {
|
|
267
|
-
var parent = tile.parent;
|
|
268
|
-
if (!parent) {
|
|
269
|
-
return true;
|
|
270
|
-
} else {
|
|
271
|
-
return this.isTileLoaded(parent);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
}, {
|
|
275
|
-
key: "isTileAllLoad",
|
|
276
|
-
value: function isTileAllLoad(tile) {
|
|
277
|
-
var tileLoaded = this.isTileLoaded(tile);
|
|
278
|
-
var tileChildLoaded = this.isTileChildLoaded(tile);
|
|
279
|
-
var tileParentLoaded = this.isTileParentLoaded(tile);
|
|
280
|
-
return tileLoaded && tileChildLoaded && tileParentLoaded;
|
|
281
|
-
}
|
|
282
|
-
}, {
|
|
283
|
-
key: "destroy",
|
|
284
|
-
value: function destroy() {
|
|
285
|
-
this.tileCache.clear();
|
|
286
|
-
this.tileLayerCache.clear();
|
|
287
|
-
}
|
|
288
|
-
}]);
|
|
289
|
-
return Base;
|
|
290
|
-
}();
|
package/es/tile/style/utils.d.ts
DELETED
package/es/tile/style/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
export function updateLayersConfig(layers, key, value) {
|
|
3
|
-
layers.map(function (layer) {
|
|
4
|
-
if (key === 'mask') {
|
|
5
|
-
// Tip: 栅格瓦片生效、设置全局的 mask、瓦片被全局的 mask 影响
|
|
6
|
-
layer.style({
|
|
7
|
-
mask: value
|
|
8
|
-
});
|
|
9
|
-
} else {
|
|
10
|
-
layer.updateLayerConfig(_defineProperty({}, key, value));
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}
|