@antv/l7-layers 2.17.2 → 2.17.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.
Files changed (242) hide show
  1. package/es/Geometry/index.js +31 -9
  2. package/es/Geometry/models/billboard.js +89 -51
  3. package/es/Geometry/models/plane.js +143 -81
  4. package/es/Geometry/models/sprite.js +118 -60
  5. package/es/canvas/index.js +33 -10
  6. package/es/canvas/models/canvas.js +97 -41
  7. package/es/citybuliding/building.js +27 -8
  8. package/es/citybuliding/models/build.js +82 -57
  9. package/es/core/BaseLayer.js +478 -313
  10. package/es/core/BaseModel.js +80 -51
  11. package/es/core/CommonStyleAttribute.js +5 -2
  12. package/es/core/LayerPickService.js +32 -21
  13. package/es/core/TextureService.js +13 -0
  14. package/es/core/interface.js +24 -17
  15. package/es/core/shape/Path.js +20 -13
  16. package/es/core/shape/extrude.js +39 -27
  17. package/es/core/triangulation.js +136 -99
  18. package/es/earth/index.js +33 -9
  19. package/es/earth/models/atmosphere.js +54 -30
  20. package/es/earth/models/base.js +85 -47
  21. package/es/earth/models/bloomsphere.js +54 -30
  22. package/es/earth/utils.js +13 -9
  23. package/es/heatmap/index.js +40 -10
  24. package/es/heatmap/models/grid.js +52 -28
  25. package/es/heatmap/models/grid3d.js +52 -28
  26. package/es/heatmap/models/heatmap.js +149 -92
  27. package/es/heatmap/models/hexagon.js +52 -28
  28. package/es/heatmap/triangulation.js +4 -0
  29. package/es/image/index.js +28 -9
  30. package/es/image/models/image.js +100 -66
  31. package/es/index.js +17 -9
  32. package/es/line/index.js +35 -9
  33. package/es/line/models/arc.js +114 -64
  34. package/es/line/models/arc_3d.js +102 -58
  35. package/es/line/models/earthArc_3d.js +105 -60
  36. package/es/line/models/flow.js +60 -36
  37. package/es/line/models/great_circle.js +94 -53
  38. package/es/line/models/line.js +138 -86
  39. package/es/line/models/linearline.js +76 -43
  40. package/es/line/models/simpleLine.js +69 -39
  41. package/es/line/models/wall.js +92 -52
  42. package/es/mask/index.js +28 -9
  43. package/es/mask/models/fill.js +54 -29
  44. package/es/plugins/DataMappingPlugin.js +114 -78
  45. package/es/plugins/DataSourcePlugin.js +68 -45
  46. package/es/plugins/FeatureScalePlugin.js +122 -67
  47. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  48. package/es/plugins/LayerMaskPlugin.js +11 -3
  49. package/es/plugins/LayerModelPlugin.js +108 -69
  50. package/es/plugins/LayerStylePlugin.js +9 -3
  51. package/es/plugins/LightingPlugin.js +18 -12
  52. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  53. package/es/plugins/PixelPickingPlugin.js +21 -12
  54. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  55. package/es/plugins/ShaderUniformPlugin.js +27 -13
  56. package/es/plugins/UpdateModelPlugin.js +5 -0
  57. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  58. package/es/point/index.js +78 -26
  59. package/es/point/models/earthExtrude.js +95 -58
  60. package/es/point/models/earthFill.js +80 -52
  61. package/es/point/models/extrude.js +94 -57
  62. package/es/point/models/fill.js +81 -56
  63. package/es/point/models/fillmage.js +100 -60
  64. package/es/point/models/image.js +83 -47
  65. package/es/point/models/index.js +2 -2
  66. package/es/point/models/normal.js +54 -30
  67. package/es/point/models/radar.js +63 -38
  68. package/es/point/models/simplePoint.js +62 -38
  69. package/es/point/models/text.js +296 -199
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +41 -11
  72. package/es/polygon/models/extrude.js +135 -87
  73. package/es/polygon/models/fill.js +79 -50
  74. package/es/polygon/models/index.js +2 -3
  75. package/es/polygon/models/ocean.js +76 -42
  76. package/es/polygon/models/water.js +71 -37
  77. package/es/raster/buffers/triangulation.js +4 -2
  78. package/es/raster/index.js +32 -9
  79. package/es/raster/models/raster.js +116 -80
  80. package/es/raster/models/rasterRgb.js +127 -84
  81. package/es/raster/models/rasterTerrainRgb.js +84 -56
  82. package/es/tile/interaction/getRasterData.js +20 -14
  83. package/es/tile/interaction/utils.js +9 -7
  84. package/es/tile/manager/base.js +96 -63
  85. package/es/tile/service/TileLayerService.js +55 -33
  86. package/es/tile/service/TilePickService.js +40 -26
  87. package/es/tile/service/TileSourceService.js +7 -3
  88. package/es/tile/tileFactory/DebugTile.js +46 -29
  89. package/es/tile/tileFactory/ImageTile.js +38 -20
  90. package/es/tile/tileFactory/MaskTile.js +43 -22
  91. package/es/tile/tileFactory/RasterRGBTile.js +42 -22
  92. package/es/tile/tileFactory/RasterTerrainRGBTile.js +38 -20
  93. package/es/tile/tileFactory/RasterTile.js +53 -30
  94. package/es/tile/tileFactory/Tile.js +97 -63
  95. package/es/tile/tileFactory/VectorTile.js +68 -41
  96. package/es/tile/tileFactory/index.js +11 -0
  97. package/es/tile/tileFactory/layers/TileDebugLayer.js +27 -6
  98. package/es/tile/tileFactory/util.js +3 -0
  99. package/es/tile/tileLayer/BaseLayer.js +146 -105
  100. package/es/tile/utils.js +1 -1
  101. package/es/utils/blend.js +2 -0
  102. package/es/utils/collision-index.js +16 -9
  103. package/es/utils/extrude_polyline.js +149 -101
  104. package/es/utils/grid-index.js +27 -2
  105. package/es/utils/identityScale.js +8 -0
  106. package/es/utils/layerData.js +44 -30
  107. package/es/utils/multiPassRender.js +13 -11
  108. package/es/utils/polylineNormal.js +37 -31
  109. package/es/utils/simpleLine.js +16 -2
  110. package/es/utils/stencil.js +3 -2
  111. package/es/utils/symbol-layout.js +53 -27
  112. package/es/wind/index.js +29 -9
  113. package/es/wind/models/utils.js +51 -26
  114. package/es/wind/models/wind.js +147 -101
  115. package/es/wind/models/windRender.js +66 -53
  116. package/lib/Geometry/index.js +38 -9
  117. package/lib/Geometry/models/billboard.js +97 -51
  118. package/lib/Geometry/models/index.js +5 -0
  119. package/lib/Geometry/models/plane.js +151 -79
  120. package/lib/Geometry/models/sprite.js +127 -60
  121. package/lib/canvas/index.js +40 -10
  122. package/lib/canvas/models/canvas.js +101 -41
  123. package/lib/canvas/models/index.js +3 -0
  124. package/lib/citybuliding/building.js +35 -8
  125. package/lib/citybuliding/models/build.js +92 -57
  126. package/lib/core/BaseLayer.js +469 -313
  127. package/lib/core/BaseModel.js +90 -51
  128. package/lib/core/CommonStyleAttribute.js +7 -2
  129. package/lib/core/LayerPickService.js +37 -21
  130. package/lib/core/TextureService.js +16 -0
  131. package/lib/core/interface.js +31 -21
  132. package/lib/core/schema.js +1 -0
  133. package/lib/core/shape/Path.js +31 -14
  134. package/lib/core/shape/extrude.js +62 -27
  135. package/lib/core/triangulation.js +177 -98
  136. package/lib/earth/index.js +43 -9
  137. package/lib/earth/models/atmosphere.js +63 -30
  138. package/lib/earth/models/base.js +90 -47
  139. package/lib/earth/models/bloomsphere.js +63 -30
  140. package/lib/earth/utils.js +31 -7
  141. package/lib/heatmap/index.js +48 -10
  142. package/lib/heatmap/models/grid.js +60 -28
  143. package/lib/heatmap/models/grid3d.js +60 -28
  144. package/lib/heatmap/models/heatmap.js +166 -92
  145. package/lib/heatmap/models/hexagon.js +60 -28
  146. package/lib/heatmap/models/index.js +6 -0
  147. package/lib/heatmap/triangulation.js +5 -0
  148. package/lib/image/index.js +36 -9
  149. package/lib/image/models/image.js +109 -66
  150. package/lib/image/models/index.js +3 -0
  151. package/lib/index.js +61 -7
  152. package/lib/line/index.js +40 -9
  153. package/lib/line/models/arc.js +124 -62
  154. package/lib/line/models/arc_3d.js +113 -56
  155. package/lib/line/models/earthArc_3d.js +115 -58
  156. package/lib/line/models/flow.js +70 -36
  157. package/lib/line/models/great_circle.js +104 -53
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +146 -84
  160. package/lib/line/models/linearline.js +88 -43
  161. package/lib/line/models/simpleLine.js +79 -39
  162. package/lib/line/models/wall.js +103 -52
  163. package/lib/mask/index.js +36 -9
  164. package/lib/mask/models/fill.js +63 -29
  165. package/lib/mask/models/index.js +3 -0
  166. package/lib/plugins/DataMappingPlugin.js +125 -78
  167. package/lib/plugins/DataSourcePlugin.js +76 -45
  168. package/lib/plugins/FeatureScalePlugin.js +138 -67
  169. package/lib/plugins/LayerAnimateStylePlugin.js +10 -0
  170. package/lib/plugins/LayerMaskPlugin.js +17 -4
  171. package/lib/plugins/LayerModelPlugin.js +117 -70
  172. package/lib/plugins/LayerStylePlugin.js +14 -4
  173. package/lib/plugins/LightingPlugin.js +25 -12
  174. package/lib/plugins/MultiPassRendererPlugin.js +22 -11
  175. package/lib/plugins/PixelPickingPlugin.js +27 -12
  176. package/lib/plugins/RegisterStyleAttributePlugin.js +19 -5
  177. package/lib/plugins/ShaderUniformPlugin.js +34 -13
  178. package/lib/plugins/UpdateModelPlugin.js +10 -1
  179. package/lib/plugins/UpdateStyleAttributePlugin.js +16 -5
  180. package/lib/point/index.js +83 -26
  181. package/lib/point/models/earthExtrude.js +106 -58
  182. package/lib/point/models/earthFill.js +110 -52
  183. package/lib/point/models/extrude.js +103 -57
  184. package/lib/point/models/fill.js +90 -54
  185. package/lib/point/models/fillmage.js +107 -58
  186. package/lib/point/models/image.js +92 -47
  187. package/lib/point/models/index.js +12 -1
  188. package/lib/point/models/normal.js +64 -30
  189. package/lib/point/models/radar.js +72 -38
  190. package/lib/point/models/simplePoint.js +72 -38
  191. package/lib/point/models/text.js +305 -199
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +146 -87
  195. package/lib/polygon/models/fill.js +89 -50
  196. package/lib/polygon/models/index.js +14 -2
  197. package/lib/polygon/models/ocean.js +88 -42
  198. package/lib/polygon/models/water.js +82 -37
  199. package/lib/raster/buffers/triangulation.js +7 -3
  200. package/lib/raster/index.js +40 -9
  201. package/lib/raster/models/index.js +5 -0
  202. package/lib/raster/models/raster.js +125 -80
  203. package/lib/raster/models/rasterRgb.js +139 -84
  204. package/lib/raster/models/rasterTerrainRgb.js +93 -56
  205. package/lib/tile/interaction/getRasterData.js +25 -14
  206. package/lib/tile/interaction/utils.js +19 -7
  207. package/lib/tile/manager/base.js +104 -63
  208. package/lib/tile/service/TileLayerService.js +60 -33
  209. package/lib/tile/service/TilePickService.js +48 -26
  210. package/lib/tile/service/TileSourceService.js +16 -2
  211. package/lib/tile/style/utils.js +3 -0
  212. package/lib/tile/tileFactory/DebugTile.js +54 -29
  213. package/lib/tile/tileFactory/ImageTile.js +46 -20
  214. package/lib/tile/tileFactory/MaskTile.js +51 -22
  215. package/lib/tile/tileFactory/RasterRGBTile.js +50 -22
  216. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +46 -20
  217. package/lib/tile/tileFactory/RasterTile.js +63 -30
  218. package/lib/tile/tileFactory/Tile.js +102 -63
  219. package/lib/tile/tileFactory/VectorTile.js +76 -41
  220. package/lib/tile/tileFactory/index.js +25 -0
  221. package/lib/tile/tileFactory/layers/TileDebugLayer.js +32 -6
  222. package/lib/tile/tileFactory/util.js +9 -0
  223. package/lib/tile/tileLayer/BaseLayer.js +153 -105
  224. package/lib/tile/utils.js +5 -1
  225. package/lib/utils/blend.js +5 -0
  226. package/lib/utils/collision-index.js +25 -9
  227. package/lib/utils/extrude_polyline.js +181 -101
  228. package/lib/utils/grid-index.js +28 -2
  229. package/lib/utils/identityScale.js +9 -0
  230. package/lib/utils/layerData.js +49 -30
  231. package/lib/utils/multiPassRender.js +16 -11
  232. package/lib/utils/polylineNormal.js +66 -31
  233. package/lib/utils/simpleLine.js +21 -2
  234. package/lib/utils/stencil.js +4 -0
  235. package/lib/utils/symbol-layout.js +55 -27
  236. package/lib/wind/index.js +37 -9
  237. package/lib/wind/models/index.js +3 -0
  238. package/lib/wind/models/utils.js +62 -26
  239. package/lib/wind/models/wind.js +157 -101
  240. package/lib/wind/models/windRender.js +71 -53
  241. package/lib/wind/models/windShader.js +1 -0
  242. package/package.json +7 -7
@@ -9,50 +9,66 @@ import { updateLayersConfig } from "../style/utils";
9
9
  export var Base = /*#__PURE__*/function () {
10
10
  function Base() {
11
11
  _classCallCheck(this, Base);
12
+
12
13
  _defineProperty(this, "tileCache", new Map());
14
+
13
15
  _defineProperty(this, "tileLayerCache", new Map());
14
16
  }
17
+
15
18
  _createClass(Base, [{
16
19
  key: "initTileLayers",
17
20
  value: function () {
18
21
  var _initTileLayers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layers, tile) {
19
22
  var _this = this;
23
+
20
24
  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();
25
+ while (1) {
26
+ switch (_context2.prev = _context2.next) {
27
+ case 0:
28
+ return _context2.abrupt("return", Promise.all(layers.map( /*#__PURE__*/function () {
29
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
30
+ var container;
31
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
32
+ while (1) {
33
+ switch (_context.prev = _context.next) {
34
+ case 0:
35
+ container = createLayerContainer(_this.parent.sceneContainer);
36
+ layer.setContainer(container, _this.parent.sceneContainer);
37
+ _context.next = 4;
38
+ return layer.init();
39
+
40
+ case 4:
41
+ _this.addChild(layer);
42
+
43
+ tile.layerLoad();
44
+
45
+ _this.render();
46
+
47
+ case 7:
48
+ case "end":
49
+ return _context.stop();
50
+ }
51
+ }
52
+ }, _callee);
53
+ }));
54
+
55
+ return function (_x3) {
56
+ return _ref.apply(this, arguments);
57
+ };
58
+ }())));
59
+
60
+ case 1:
61
+ case "end":
62
+ return _context2.stop();
63
+ }
50
64
  }
51
65
  }, _callee2);
52
66
  }));
67
+
53
68
  function initTileLayers(_x, _x2) {
54
69
  return _initTileLayers.apply(this, arguments);
55
70
  }
71
+
56
72
  return initTileLayers;
57
73
  }()
58
74
  }, {
@@ -64,48 +80,55 @@ export var Base = /*#__PURE__*/function () {
64
80
  key: "hasTile",
65
81
  value: function hasTile(tile) {
66
82
  return this.tileCache.has(tile.key);
67
- }
83
+ } // 添加图层
68
84
 
69
- // 添加图层
70
85
  }, {
71
86
  key: "addTile",
72
87
  value: function () {
73
88
  var _addTile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(tile) {
74
89
  var layerCollections;
75
90
  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();
91
+ while (1) {
92
+ switch (_context3.prev = _context3.next) {
93
+ case 0:
94
+ if (!this.hasTile(tile)) {
95
+ _context3.next = 2;
96
+ break;
97
+ }
98
+
99
+ return _context3.abrupt("return", {
100
+ layers: []
101
+ });
102
+
103
+ case 2:
104
+ // 存储当前 tile
105
+ this.tileCache.set(tile.key, tile); // 创建 tile 对应的 layers
106
+
107
+ layerCollections = this.tileFactory.createTile(tile, this.initOptions); // // 初始化图层
108
+
109
+ _context3.next = 6;
110
+ return this.initTileLayers(layerCollections.layers, tile);
111
+
112
+ case 6:
113
+ this.tileLayerCache.set(tile.key, layerCollections.layers); // const visible = tile.parent ? tile.parent.children.every(t=>this.tileLayerCache.has(t.key)) : true
114
+ // tile.parent?.children.forEach((t)=>{
115
+ // updateLayersConfig(this.getLayers(t),'visible',visible)
116
+ // })
117
+
118
+ return _context3.abrupt("return", layerCollections);
119
+
120
+ case 8:
121
+ case "end":
122
+ return _context3.stop();
123
+ }
103
124
  }
104
125
  }, _callee3, this);
105
126
  }));
127
+
106
128
  function addTile(_x4) {
107
129
  return _addTile.apply(this, arguments);
108
130
  }
131
+
109
132
  return addTile;
110
133
  }()
111
134
  }, {
@@ -125,6 +148,7 @@ export var Base = /*#__PURE__*/function () {
125
148
  key: "addChildren",
126
149
  value: function addChildren(layers) {
127
150
  var _this$children;
151
+
128
152
  (_this$children = this.children).push.apply(_this$children, _toConsumableArray(layers));
129
153
  }
130
154
  }, {
@@ -143,9 +167,11 @@ export var Base = /*#__PURE__*/function () {
143
167
  key: "removeChild",
144
168
  value: function removeChild(layer) {
145
169
  var layerIndex = this.children.indexOf(layer);
170
+
146
171
  if (layerIndex > -1) {
147
172
  this.children.splice(layerIndex, 1);
148
173
  }
174
+
149
175
  layer.destroy();
150
176
  }
151
177
  }, {
@@ -154,6 +180,7 @@ export var Base = /*#__PURE__*/function () {
154
180
  if (!tile) {
155
181
  return [];
156
182
  }
183
+
157
184
  return this.tileLayerCache.get(tile.key) || [];
158
185
  }
159
186
  }, {
@@ -178,8 +205,7 @@ export var Base = /*#__PURE__*/function () {
178
205
  }
179
206
  }, {
180
207
  key: "initTileFactory",
181
- value: function initTileFactory() {
182
- // this.tileFactory = new TileFactory({
208
+ value: function initTileFactory() {// this.tileFactory = new TileFactory({
183
209
  // parent: this.parent,
184
210
  // mapService: this.mapService,
185
211
  // rendererService: this.rendererService,
@@ -200,9 +226,11 @@ export var Base = /*#__PURE__*/function () {
200
226
  key: "updateTileVisible",
201
227
  value: function updateTileVisible(tile, layerService) {
202
228
  var layers = this.getLayers(tile);
229
+
203
230
  if (layers.length === 0) {
204
231
  return;
205
232
  }
233
+
206
234
  if (tile.isVisible) {
207
235
  // 如果可见直接进行渲染,父级发
208
236
  updateLayersConfig(layers, 'visible', tile.isVisible);
@@ -215,16 +243,16 @@ export var Base = /*#__PURE__*/function () {
215
243
  // console.log(`${t.x}/${t.y}/${t.z}`)
216
244
  // })
217
245
  updateLayersConfig(layers, 'visible', tile.isVisible);
218
- }
219
-
220
- // this.listenLoad(tile, () => {
246
+ } // this.listenLoad(tile, () => {
221
247
  // this.isTileAllLoad(tile) && updateLayersConfig(layers, 'visible', tile.isVisible);
222
248
  // })
249
+
223
250
  }
224
251
  }, {
225
252
  key: "listenLoad",
226
253
  value: function listenLoad(tile, callback) {
227
254
  var _tile$parent;
255
+
228
256
  tile.once('layerLoaded', function () {
229
257
  callback();
230
258
  });
@@ -243,6 +271,7 @@ export var Base = /*#__PURE__*/function () {
243
271
  if (tile.isLoad) {
244
272
  return true;
245
273
  }
274
+
246
275
  var isLoad = this.getLayers(tile).length === tile.loadedLayers;
247
276
  tile.isLoad = isLoad;
248
277
  return isLoad;
@@ -251,9 +280,11 @@ export var Base = /*#__PURE__*/function () {
251
280
  key: "isTileChildLoaded",
252
281
  value: function isTileChildLoaded(tile) {
253
282
  var _this2 = this;
283
+
254
284
  if (tile.isChildLoad) {
255
285
  return true;
256
286
  }
287
+
257
288
  var children = tile.children;
258
289
  var isLoad = children.filter(function (child) {
259
290
  return _this2.isTileLoaded(child);
@@ -265,6 +296,7 @@ export var Base = /*#__PURE__*/function () {
265
296
  key: "isTileParentLoaded",
266
297
  value: function isTileParentLoaded(tile) {
267
298
  var parent = tile.parent;
299
+
268
300
  if (!parent) {
269
301
  return true;
270
302
  } else {
@@ -286,5 +318,6 @@ export var Base = /*#__PURE__*/function () {
286
318
  this.tileLayerCache.clear();
287
319
  }
288
320
  }]);
321
+
289
322
  return Base;
290
323
  }();
@@ -9,18 +9,22 @@ export var TileLayerService = /*#__PURE__*/function () {
9
9
  /**
10
10
  * tileResource 用于存储瓦片的全局资源
11
11
  */
12
-
13
12
  function TileLayerService(_ref) {
14
13
  var rendererService = _ref.rendererService,
15
- layerService = _ref.layerService,
16
- parent = _ref.parent;
14
+ layerService = _ref.layerService,
15
+ parent = _ref.parent;
16
+
17
17
  _classCallCheck(this, TileLayerService);
18
+
18
19
  _defineProperty(this, "tileResource", new Map());
20
+
19
21
  _defineProperty(this, "layerTiles", []);
22
+
20
23
  this.rendererService = rendererService;
21
24
  this.layerService = layerService;
22
25
  this.parent = parent;
23
26
  }
27
+
24
28
  _createClass(TileLayerService, [{
25
29
  key: "tiles",
26
30
  get: function get() {
@@ -60,6 +64,7 @@ export var TileLayerService = /*#__PURE__*/function () {
60
64
  return t.key === tileKey;
61
65
  });
62
66
  var tile = this.layerTiles.splice(index, 1);
67
+
63
68
  if (tile[0]) {
64
69
  tile[0].destroy();
65
70
  }
@@ -67,8 +72,7 @@ export var TileLayerService = /*#__PURE__*/function () {
67
72
  }, {
68
73
  key: "updateTileVisible",
69
74
  value: function updateTileVisible(sourceTile) {
70
- var tile = this.getTile(sourceTile.key);
71
- // if(sourceTile.isVisible) {
75
+ var tile = this.getTile(sourceTile.key); // if(sourceTile.isVisible) {
72
76
  // // 不可见 => 可见 兄弟节点加载完成
73
77
  // if(sourceTile.parent) {
74
78
  // const flag = this.isChildrenLoaded(sourceTile.parent)
@@ -76,7 +80,6 @@ export var TileLayerService = /*#__PURE__*/function () {
76
80
  // } else {
77
81
  // tile?.updateVisible(true);
78
82
  // }
79
-
80
83
  // } else {
81
84
  // // 可见 => 不可见 兄弟节点加载完成
82
85
  // if(sourceTile.parent) {
@@ -86,8 +89,8 @@ export var TileLayerService = /*#__PURE__*/function () {
86
89
  // tile?.updateVisible(false);
87
90
  // }
88
91
  // }
89
- tile === null || tile === void 0 ? void 0 : tile.updateVisible(sourceTile.isVisible);
90
- // if (sourceTile.isVisible) {
92
+
93
+ tile === null || tile === void 0 ? void 0 : tile.updateVisible(sourceTile.isVisible); // if (sourceTile.isVisible) {
91
94
  // tile?.updateVisible(sourceTile.isVisible);
92
95
  // } else {
93
96
  // this.removeTile(sourceTile.key);
@@ -97,26 +100,34 @@ export var TileLayerService = /*#__PURE__*/function () {
97
100
  key: "isParentLoaded",
98
101
  value: function isParentLoaded(sourceTile) {
99
102
  var parentTile = sourceTile.parent;
103
+
100
104
  if (!parentTile) {
101
105
  return true;
102
106
  }
107
+
103
108
  var tile = this.getTile(parentTile === null || parentTile === void 0 ? void 0 : parentTile.key);
109
+
104
110
  if (tile !== null && tile !== void 0 && tile.isLoaded) {
105
111
  // 递归父级
106
112
  return true;
107
113
  }
114
+
108
115
  return false;
109
116
  }
110
117
  }, {
111
118
  key: "isChildrenLoaded",
112
119
  value: function isChildrenLoaded(sourceTile) {
113
120
  var _this = this;
121
+
114
122
  var childrenTile = sourceTile === null || sourceTile === void 0 ? void 0 : sourceTile.children;
123
+
115
124
  if (childrenTile.length === 0) {
116
125
  return true;
117
126
  }
127
+
118
128
  return childrenTile.some(function (tile) {
119
129
  var tileLayer = _this.getTile(tile === null || tile === void 0 ? void 0 : tile.key);
130
+
120
131
  return (tileLayer === null || tileLayer === void 0 ? void 0 : tileLayer.isLoaded) === false;
121
132
  });
122
133
  }
@@ -125,39 +136,49 @@ export var TileLayerService = /*#__PURE__*/function () {
125
136
  value: function () {
126
137
  var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
127
138
  var _this2 = this;
139
+
128
140
  var layers, renders;
129
141
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
130
- while (1) switch (_context2.prev = _context2.next) {
131
- case 0:
132
- layers = this.getRenderLayers();
133
- renders = layers.map( /*#__PURE__*/function () {
134
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
135
- return _regeneratorRuntime.wrap(function _callee$(_context) {
136
- while (1) switch (_context.prev = _context.next) {
137
- case 0:
138
- _context.next = 2;
139
- return _this2.layerService.renderTileLayer(layer);
140
- case 2:
141
- case "end":
142
- return _context.stop();
143
- }
144
- }, _callee);
145
- }));
146
- return function (_x) {
147
- return _ref2.apply(this, arguments);
148
- };
149
- }());
150
- _context2.next = 4;
151
- return Promise.all(renders);
152
- case 4:
153
- case "end":
154
- return _context2.stop();
142
+ while (1) {
143
+ switch (_context2.prev = _context2.next) {
144
+ case 0:
145
+ layers = this.getRenderLayers();
146
+ renders = layers.map( /*#__PURE__*/function () {
147
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(layer) {
148
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
149
+ while (1) {
150
+ switch (_context.prev = _context.next) {
151
+ case 0:
152
+ _context.next = 2;
153
+ return _this2.layerService.renderTileLayer(layer);
154
+
155
+ case 2:
156
+ case "end":
157
+ return _context.stop();
158
+ }
159
+ }
160
+ }, _callee);
161
+ }));
162
+
163
+ return function (_x) {
164
+ return _ref2.apply(this, arguments);
165
+ };
166
+ }());
167
+ _context2.next = 4;
168
+ return Promise.all(renders);
169
+
170
+ case 4:
171
+ case "end":
172
+ return _context2.stop();
173
+ }
155
174
  }
156
175
  }, _callee2, this);
157
176
  }));
177
+
158
178
  function render() {
159
179
  return _render.apply(this, arguments);
160
180
  }
181
+
161
182
  return render;
162
183
  }()
163
184
  }, {
@@ -198,5 +219,6 @@ export var TileLayerService = /*#__PURE__*/function () {
198
219
  this.tileResource.clear();
199
220
  }
200
221
  }]);
222
+
201
223
  return TileLayerService;
202
224
  }();
@@ -11,20 +11,25 @@ var ACTIVE = 'active';
11
11
  export var TilePickService = /*#__PURE__*/function () {
12
12
  function TilePickService(_ref) {
13
13
  var layerService = _ref.layerService,
14
- tileLayerService = _ref.tileLayerService,
15
- parent = _ref.parent;
14
+ tileLayerService = _ref.tileLayerService,
15
+ parent = _ref.parent;
16
+
16
17
  _classCallCheck(this, TilePickService);
18
+
17
19
  _defineProperty(this, "tilePickID", new Map());
20
+
18
21
  this.layerService = layerService;
19
22
  this.tileLayerService = tileLayerService;
20
23
  this.parent = parent;
21
24
  this.tileSourceService = new TileSourceService();
22
25
  }
26
+
23
27
  _createClass(TilePickService, [{
24
28
  key: "pickRender",
25
29
  value: function pickRender(target) {
26
30
  // 一个 TileLayer 有多个 Tile,但是会同时触发事件的只有一个 Tile
27
31
  var tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
32
+
28
33
  if (tile) {
29
34
  // TODO 多图层拾取
30
35
  var pickLayer = tile.getMainLayer();
@@ -36,14 +41,18 @@ export var TilePickService = /*#__PURE__*/function () {
36
41
  value: function pick(layer, target) {
37
42
  var container = this.parent.getContainer();
38
43
  var pickingService = container.get(TYPES.IPickingService);
44
+
39
45
  if (layer.type === 'RasterLayer') {
40
46
  var tile = this.tileLayerService.getVisibleTileBylngLat(target.lngLat);
47
+
41
48
  if (tile && tile.getMainLayer() !== undefined) {
42
49
  var pickLayer = tile.getMainLayer();
43
50
  return pickLayer.layerPickService.pickRasterLayer(pickLayer, target, this.parent);
44
51
  }
52
+
45
53
  return false;
46
54
  }
55
+
47
56
  this.pickRender(target);
48
57
  return pickingService.pickFromPickingFBO(layer, target);
49
58
  }
@@ -52,9 +61,10 @@ export var TilePickService = /*#__PURE__*/function () {
52
61
  value: function selectFeature(pickedColors) {
53
62
  // @ts-ignore
54
63
  var _pickedColors = _slicedToArray(pickedColors, 3),
55
- r = _pickedColors[0],
56
- g = _pickedColors[1],
57
- b = _pickedColors[2];
64
+ r = _pickedColors[0],
65
+ g = _pickedColors[1],
66
+ b = _pickedColors[2];
67
+
58
68
  var id = this.color2PickId(r, g, b);
59
69
  this.tilePickID.set(SELECT, id);
60
70
  this.updateHighLight(r, g, b, SELECT);
@@ -64,9 +74,10 @@ export var TilePickService = /*#__PURE__*/function () {
64
74
  value: function highlightPickedFeature(pickedColors) {
65
75
  // @ts-ignore
66
76
  var _pickedColors2 = _slicedToArray(pickedColors, 3),
67
- r = _pickedColors2[0],
68
- g = _pickedColors2[1],
69
- b = _pickedColors2[2];
77
+ r = _pickedColors2[0],
78
+ g = _pickedColors2[1],
79
+ b = _pickedColors2[2];
80
+
70
81
  var id = this.color2PickId(r, g, b);
71
82
  this.tilePickID.set(ACTIVE, id);
72
83
  this.updateHighLight(r, g, b, ACTIVE);
@@ -76,10 +87,12 @@ export var TilePickService = /*#__PURE__*/function () {
76
87
  value: function updateHighLight(r, g, b, type) {
77
88
  this.tileLayerService.tiles.map(function (tile) {
78
89
  var layer = tile.getMainLayer();
90
+
79
91
  switch (type) {
80
92
  case SELECT:
81
93
  layer === null || layer === void 0 ? void 0 : layer.hooks.beforeSelect.call([r, g, b]);
82
94
  break;
95
+
83
96
  case ACTIVE:
84
97
  layer === null || layer === void 0 ? void 0 : layer.hooks.beforeHighlight.call([r, g, b]);
85
98
  break;
@@ -91,21 +104,25 @@ export var TilePickService = /*#__PURE__*/function () {
91
104
  value: function setPickState() {
92
105
  var selectColor = this.tilePickID.get(SELECT);
93
106
  var activeColor = this.tilePickID.get(ACTIVE);
107
+
94
108
  if (selectColor) {
95
109
  var _this$pickId2Color = this.pickId2Color(selectColor),
96
- _this$pickId2Color2 = _slicedToArray(_this$pickId2Color, 3),
97
- r = _this$pickId2Color2[0],
98
- g = _this$pickId2Color2[1],
99
- b = _this$pickId2Color2[2];
110
+ _this$pickId2Color2 = _slicedToArray(_this$pickId2Color, 3),
111
+ r = _this$pickId2Color2[0],
112
+ g = _this$pickId2Color2[1],
113
+ b = _this$pickId2Color2[2];
114
+
100
115
  this.updateHighLight(r, g, b, SELECT);
101
116
  return;
102
117
  }
118
+
103
119
  if (activeColor) {
104
120
  var _this$pickId2Color3 = this.pickId2Color(activeColor),
105
- _this$pickId2Color4 = _slicedToArray(_this$pickId2Color3, 3),
106
- _r = _this$pickId2Color4[0],
107
- _g = _this$pickId2Color4[1],
108
- _b = _this$pickId2Color4[2];
121
+ _this$pickId2Color4 = _slicedToArray(_this$pickId2Color3, 3),
122
+ _r = _this$pickId2Color4[0],
123
+ _g = _this$pickId2Color4[1],
124
+ _b = _this$pickId2Color4[2];
125
+
109
126
  this.updateHighLight(_r, _g, _b, ACTIVE);
110
127
  return;
111
128
  }
@@ -120,36 +137,33 @@ export var TilePickService = /*#__PURE__*/function () {
120
137
  value: function pickId2Color(str) {
121
138
  return encodePickingColor(str);
122
139
  }
123
-
124
140
  /** 从瓦片中根据数据 */
141
+
125
142
  }, {
126
143
  key: "getFeatureById",
127
144
  value: function getFeatureById(pickedFeatureIdx) {
128
145
  // 提取当前可见瓦片
129
146
  var tiles = this.tileLayerService.getTiles().filter(function (tile) {
130
147
  return tile.visible;
131
- });
132
- // 提取当前可见瓦片中匹配 ID 的 feature 列表
148
+ }); // 提取当前可见瓦片中匹配 ID 的 feature 列表
149
+
133
150
  var features = [];
134
151
  tiles.forEach(function (tile) {
135
152
  features.push.apply(features, _toConsumableArray(tile.getFeatureById(pickedFeatureIdx)));
136
- });
137
-
138
- // 将 feature 列表合并后返回
153
+ }); // 将 feature 列表合并后返回
139
154
  // 统一返回成 polygon 的格式 点、线、面可以通用
140
-
141
155
  // const data = this.tileSourceService.getCombineFeature(features);
142
156
 
143
157
  return features;
144
- }
145
-
146
- // Tip: for interface define
158
+ } // Tip: for interface define
147
159
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
160
+
148
161
  }, {
149
162
  key: "pickRasterLayer",
150
163
  value: function pickRasterLayer(layer, target, parent) {
151
164
  return false;
152
165
  }
153
166
  }]);
167
+
154
168
  return TilePickService;
155
169
  }();
@@ -3,33 +3,37 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
4
  import * as turf from '@turf/helpers';
5
5
  import union from '@turf/union';
6
-
7
6
  /**
8
7
  * 专门处理 Tile 数据相关
9
8
  */
9
+
10
10
  export var TileSourceService = /*#__PURE__*/function () {
11
11
  function TileSourceService() {
12
12
  _classCallCheck(this, TileSourceService);
13
13
  }
14
+
14
15
  _createClass(TileSourceService, [{
15
16
  key: "getCombineFeature",
16
17
  value: function getCombineFeature(features) {
17
18
  var p = null;
18
19
  var properties = features[0];
19
20
  features.map(function (feature) {
20
- var polygon = turf.polygon(feature.coordinates);
21
- // tslint:disable-next-line: prefer-conditional-expression
21
+ var polygon = turf.polygon(feature.coordinates); // tslint:disable-next-line: prefer-conditional-expression
22
+
22
23
  if (p === null) {
23
24
  p = polygon;
24
25
  } else {
25
26
  p = union(p, polygon);
26
27
  }
27
28
  });
29
+
28
30
  if (properties) {
29
31
  p.properties = _objectSpread({}, properties);
30
32
  }
33
+
31
34
  return p;
32
35
  }
33
36
  }]);
37
+
34
38
  return TileSourceService;
35
39
  }();