@antv/l7-layers 2.15.5 → 2.16.1

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 (243) 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 +486 -321
  10. package/es/core/BaseModel.js +126 -97
  11. package/es/core/LayerPickService.js +32 -21
  12. package/es/core/TextureService.js +13 -0
  13. package/es/core/interface.js +24 -17
  14. package/es/core/shape/Path.js +20 -13
  15. package/es/core/shape/extrude.js +31 -10
  16. package/es/core/triangulation.js +114 -54
  17. package/es/earth/index.js +33 -9
  18. package/es/earth/models/atmosphere.js +54 -30
  19. package/es/earth/models/base.js +85 -47
  20. package/es/earth/models/bloomsphere.js +54 -30
  21. package/es/earth/utils.js +13 -9
  22. package/es/heatmap/index.js +40 -10
  23. package/es/heatmap/models/grid.js +52 -28
  24. package/es/heatmap/models/grid3d.js +52 -28
  25. package/es/heatmap/models/heatmap.js +146 -91
  26. package/es/heatmap/models/hexagon.js +52 -28
  27. package/es/heatmap/triangulation.js +4 -0
  28. package/es/image/index.js +28 -9
  29. package/es/image/models/image.js +100 -66
  30. package/es/index.js +17 -9
  31. package/es/line/index.js +34 -9
  32. package/es/line/models/arc.js +118 -66
  33. package/es/line/models/arc_3d.js +108 -60
  34. package/es/line/models/earthArc_3d.js +111 -63
  35. package/es/line/models/great_circle.js +100 -56
  36. package/es/line/models/half.js +77 -46
  37. package/es/line/models/line.js +148 -94
  38. package/es/line/models/linearline.js +80 -45
  39. package/es/line/models/simpleLine.js +74 -41
  40. package/es/line/models/wall.js +92 -52
  41. package/es/mask/index.js +28 -9
  42. package/es/mask/models/fill.js +54 -29
  43. package/es/plugins/DataMappingPlugin.js +117 -80
  44. package/es/plugins/DataSourcePlugin.js +68 -45
  45. package/es/plugins/FeatureScalePlugin.js +122 -67
  46. package/es/plugins/LayerAnimateStylePlugin.js +5 -0
  47. package/es/plugins/LayerMaskPlugin.js +11 -3
  48. package/es/plugins/LayerModelPlugin.js +104 -67
  49. package/es/plugins/LayerStylePlugin.js +9 -3
  50. package/es/plugins/LightingPlugin.js +18 -12
  51. package/es/plugins/MultiPassRendererPlugin.js +16 -11
  52. package/es/plugins/PixelPickingPlugin.js +21 -12
  53. package/es/plugins/RegisterStyleAttributePlugin.js +12 -5
  54. package/es/plugins/ShaderUniformPlugin.js +27 -13
  55. package/es/plugins/UpdateModelPlugin.js +5 -0
  56. package/es/plugins/UpdateStyleAttributePlugin.js +11 -5
  57. package/es/point/index.js +77 -26
  58. package/es/point/models/earthExtrude.js +102 -61
  59. package/es/point/models/earthFill.js +87 -57
  60. package/es/point/models/extrude.js +101 -60
  61. package/es/point/models/fill.js +100 -70
  62. package/es/point/models/fillmage.js +107 -63
  63. package/es/point/models/image.js +88 -48
  64. package/es/point/models/index.js +2 -2
  65. package/es/point/models/normal.js +54 -30
  66. package/es/point/models/radar.js +64 -40
  67. package/es/point/models/simplePoint.js +69 -41
  68. package/es/point/models/text.d.ts +2 -1
  69. package/es/point/models/text.js +305 -201
  70. package/es/point/shape/extrude.js +13 -4
  71. package/es/polygon/index.js +40 -11
  72. package/es/polygon/models/extrude.js +92 -48
  73. package/es/polygon/models/fill.js +88 -54
  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/dataMappingStyle.js +18 -8
  104. package/es/utils/extrude_polyline.js +149 -101
  105. package/es/utils/grid-index.js +27 -2
  106. package/es/utils/identityScale.js +8 -0
  107. package/es/utils/layerData.js +44 -30
  108. package/es/utils/multiPassRender.js +13 -11
  109. package/es/utils/polylineNormal.js +37 -31
  110. package/es/utils/simpleLine.js +16 -2
  111. package/es/utils/stencil.js +3 -2
  112. package/es/utils/symbol-layout.js +53 -27
  113. package/es/wind/index.js +29 -9
  114. package/es/wind/models/utils.js +51 -26
  115. package/es/wind/models/wind.js +147 -101
  116. package/es/wind/models/windRender.js +66 -53
  117. package/lib/Geometry/index.js +38 -9
  118. package/lib/Geometry/models/billboard.js +97 -51
  119. package/lib/Geometry/models/index.js +5 -0
  120. package/lib/Geometry/models/plane.js +151 -79
  121. package/lib/Geometry/models/sprite.js +127 -60
  122. package/lib/canvas/index.js +40 -10
  123. package/lib/canvas/models/canvas.js +101 -41
  124. package/lib/canvas/models/index.js +3 -0
  125. package/lib/citybuliding/building.js +35 -8
  126. package/lib/citybuliding/models/build.js +92 -57
  127. package/lib/core/BaseLayer.js +480 -321
  128. package/lib/core/BaseModel.js +139 -97
  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 +54 -10
  135. package/lib/core/triangulation.js +153 -53
  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 +162 -91
  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 +128 -64
  154. package/lib/line/models/arc_3d.js +119 -58
  155. package/lib/line/models/earthArc_3d.js +122 -61
  156. package/lib/line/models/great_circle.js +111 -56
  157. package/lib/line/models/half.js +87 -46
  158. package/lib/line/models/index.js +11 -0
  159. package/lib/line/models/line.js +156 -92
  160. package/lib/line/models/linearline.js +92 -45
  161. package/lib/line/models/simpleLine.js +84 -41
  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 +128 -80
  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 +113 -68
  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 +113 -61
  182. package/lib/point/models/earthFill.js +117 -57
  183. package/lib/point/models/extrude.js +111 -60
  184. package/lib/point/models/fill.js +109 -68
  185. package/lib/point/models/fillmage.js +115 -61
  186. package/lib/point/models/image.js +98 -48
  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 +74 -40
  190. package/lib/point/models/simplePoint.js +79 -41
  191. package/lib/point/models/text.js +314 -202
  192. package/lib/point/shape/extrude.js +20 -4
  193. package/lib/polygon/index.js +48 -11
  194. package/lib/polygon/models/extrude.js +103 -48
  195. package/lib/polygon/models/fill.js +98 -54
  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/dataMappingStyle.js +19 -8
  228. package/lib/utils/extrude_polyline.js +181 -101
  229. package/lib/utils/grid-index.js +28 -2
  230. package/lib/utils/identityScale.js +9 -0
  231. package/lib/utils/layerData.js +49 -30
  232. package/lib/utils/multiPassRender.js +16 -11
  233. package/lib/utils/polylineNormal.js +66 -31
  234. package/lib/utils/simpleLine.js +21 -2
  235. package/lib/utils/stencil.js +4 -0
  236. package/lib/utils/symbol-layout.js +55 -27
  237. package/lib/wind/index.js +37 -9
  238. package/lib/wind/models/index.js +3 -0
  239. package/lib/wind/models/utils.js +62 -26
  240. package/lib/wind/models/wind.js +157 -101
  241. package/lib/wind/models/windRender.js +71 -53
  242. package/lib/wind/models/windShader.js +1 -0
  243. package/package.json +7 -7
@@ -8,8 +8,11 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
9
9
  var _excluded = ["rasterData"];
10
10
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
+
11
12
  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); }; }
13
+
12
14
  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; } }
15
+
13
16
  import { getDefaultDomain } from '@antv/l7-utils';
14
17
  import RasterLayer from "../../raster";
15
18
  import Tile from "./Tile";
@@ -17,58 +20,74 @@ var DEFAULT_COLOR_TEXTURE_OPTION = {
17
20
  positions: [0, 1],
18
21
  colors: ['#000', '#fff']
19
22
  };
23
+
20
24
  var RasterTile = /*#__PURE__*/function (_Tile) {
21
25
  _inherits(RasterTile, _Tile);
26
+
22
27
  var _super = _createSuper(RasterTile);
28
+
23
29
  function RasterTile() {
24
30
  _classCallCheck(this, RasterTile);
31
+
25
32
  return _super.apply(this, arguments);
26
33
  }
34
+
27
35
  _createClass(RasterTile, [{
28
36
  key: "initTileLayer",
29
37
  value: function () {
30
38
  var _initTileLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
31
39
  var attributes, layerOptions, sourceOptions, _ref, rampColors, domain, layer;
40
+
32
41
  return _regeneratorRuntime.wrap(function _callee$(_context) {
33
- while (1) switch (_context.prev = _context.next) {
34
- case 0:
35
- attributes = this.parent.getLayerAttributeConfig();
36
- layerOptions = this.getLayerOptions();
37
- sourceOptions = this.getSourceOption();
38
- _ref = this.getLayerOptions(), rampColors = _ref.rampColors, domain = _ref.domain;
39
- this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain);
40
- layer = new RasterLayer(_objectSpread(_objectSpread({}, layerOptions), {}, {
41
- colorTexture: this.colorTexture
42
- })).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
43
- // tslint:disable-next-line: no-unused-expression
44
- attributes && Object.keys(attributes).forEach(function (type) {
45
- var _attributes$attr, _attributes$attr2;
46
- var attr = type;
47
- // @ts-ignore
48
- 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);
49
- });
50
- _context.next = 9;
51
- return this.addLayer(layer);
52
- case 9:
53
- this.isLoaded = true;
54
- case 10:
55
- case "end":
56
- return _context.stop();
42
+ while (1) {
43
+ switch (_context.prev = _context.next) {
44
+ case 0:
45
+ attributes = this.parent.getLayerAttributeConfig();
46
+ layerOptions = this.getLayerOptions();
47
+ sourceOptions = this.getSourceOption();
48
+ _ref = this.getLayerOptions(), rampColors = _ref.rampColors, domain = _ref.domain;
49
+ this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain);
50
+ layer = new RasterLayer(_objectSpread(_objectSpread({}, layerOptions), {}, {
51
+ colorTexture: this.colorTexture
52
+ })).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
53
+ // tslint:disable-next-line: no-unused-expression
54
+
55
+ attributes && Object.keys(attributes).forEach(function (type) {
56
+ var _attributes$attr, _attributes$attr2;
57
+
58
+ var attr = type; // @ts-ignore
59
+
60
+ 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);
61
+ });
62
+ _context.next = 9;
63
+ return this.addLayer(layer);
64
+
65
+ case 9:
66
+ this.isLoaded = true;
67
+
68
+ case 10:
69
+ case "end":
70
+ return _context.stop();
71
+ }
57
72
  }
58
73
  }, _callee, this);
59
74
  }));
75
+
60
76
  function initTileLayer() {
61
77
  return _initTileLayer.apply(this, arguments);
62
78
  }
79
+
63
80
  return initTileLayer;
64
81
  }()
65
82
  }, {
66
83
  key: "getSourceOption",
67
84
  value: function getSourceOption() {
68
85
  var rawSource = this.parent.getSource();
86
+
69
87
  var _this$sourceTile$data = this.sourceTile.data.data,
70
- rasterData = _this$sourceTile$data.rasterData,
71
- res = _objectWithoutProperties(_this$sourceTile$data, _excluded);
88
+ rasterData = _this$sourceTile$data.rasterData,
89
+ res = _objectWithoutProperties(_this$sourceTile$data, _excluded);
90
+
72
91
  return {
73
92
  data: rasterData,
74
93
  options: {
@@ -80,22 +99,24 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
80
99
  }
81
100
  };
82
101
  }
83
-
84
102
  /**
85
103
  * 用于 style 更新 colorTexture 的优化
86
104
  * @param arg
87
105
  */
106
+
88
107
  }, {
89
108
  key: "styleUpdate",
90
109
  value: function styleUpdate() {
91
110
  var _this = this;
111
+
92
112
  for (var _len = arguments.length, arg = new Array(_len), _key = 0; _key < _len; _key++) {
93
113
  arg[_key] = arguments[_key];
94
114
  }
115
+
95
116
  var _ref2 = arg,
96
- _ref2$rampColors = _ref2.rampColors,
97
- rampColors = _ref2$rampColors === void 0 ? DEFAULT_COLOR_TEXTURE_OPTION : _ref2$rampColors,
98
- domain = _ref2.domain;
117
+ _ref2$rampColors = _ref2.rampColors,
118
+ rampColors = _ref2$rampColors === void 0 ? DEFAULT_COLOR_TEXTURE_OPTION : _ref2$rampColors,
119
+ domain = _ref2.domain;
99
120
  this.colorTexture = this.parent.textureService.getColorTexture(rampColors, domain || getDefaultDomain(rampColors));
100
121
  this.layers.forEach(function (layer) {
101
122
  return layer.style({
@@ -111,6 +132,8 @@ var RasterTile = /*#__PURE__*/function (_Tile) {
111
132
  });
112
133
  }
113
134
  }]);
135
+
114
136
  return RasterTile;
115
137
  }(Tile);
138
+
116
139
  export { RasterTile as default };
@@ -8,13 +8,19 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { createLayerContainer } from '@antv/l7-core';
9
9
  import PolygonLayer from "../../polygon";
10
10
  import { isNeedMask } from "./util";
11
+
11
12
  var Tile = /*#__PURE__*/function () {
12
13
  function Tile(sourceTile, parent) {
13
14
  _classCallCheck(this, Tile);
15
+
14
16
  _defineProperty(this, "visible", true);
17
+
15
18
  _defineProperty(this, "layers", []);
19
+
16
20
  _defineProperty(this, "isLoaded", false);
21
+
17
22
  _defineProperty(this, "tileMaskLayers", []);
23
+
18
24
  this.parent = parent;
19
25
  this.sourceTile = sourceTile;
20
26
  this.x = sourceTile.x;
@@ -22,13 +28,13 @@ var Tile = /*#__PURE__*/function () {
22
28
  this.z = sourceTile.z;
23
29
  this.key = "".concat(this.x, "_").concat(this.y, "_").concat(this.z);
24
30
  }
31
+
25
32
  _createClass(Tile, [{
26
33
  key: "getLayers",
27
34
  value: function getLayers() {
28
35
  return this.layers;
29
- }
36
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
37
 
31
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
38
  }, {
33
39
  key: "styleUpdate",
34
40
  value: function styleUpdate() {
@@ -38,18 +44,20 @@ var Tile = /*#__PURE__*/function () {
38
44
  key: "lnglatInBounds",
39
45
  value: function lnglatInBounds(lnglat) {
40
46
  var _this$sourceTile$boun = _slicedToArray(this.sourceTile.bounds, 4),
41
- minLng = _this$sourceTile$boun[0],
42
- minLat = _this$sourceTile$boun[1],
43
- maxLng = _this$sourceTile$boun[2],
44
- maxLat = _this$sourceTile$boun[3];
47
+ minLng = _this$sourceTile$boun[0],
48
+ minLat = _this$sourceTile$boun[1],
49
+ maxLng = _this$sourceTile$boun[2],
50
+ maxLat = _this$sourceTile$boun[3];
51
+
45
52
  var lng = lnglat.lng,
46
- lat = lnglat.lat;
53
+ lat = lnglat.lat;
47
54
  return lng >= minLng && lng <= maxLng && lat >= minLat && lat <= maxLat;
48
55
  }
49
56
  }, {
50
57
  key: "getLayerOptions",
51
58
  value: function getLayerOptions() {
52
59
  var _options$maskLayers;
60
+
53
61
  var options = this.parent.getLayerConfig();
54
62
  return _objectSpread(_objectSpread({}, options), {}, {
55
63
  textAllowOverlap: true,
@@ -59,14 +67,16 @@ var Tile = /*#__PURE__*/function () {
59
67
  tileMask: isNeedMask(this.parent.type),
60
68
  mask: options.mask || ((_options$maskLayers = options.maskLayers) === null || _options$maskLayers === void 0 ? void 0 : _options$maskLayers.length) !== 0 && options.enableMask
61
69
  });
62
- }
63
- // 获取Mask 图层
70
+ } // 获取Mask 图层
71
+
64
72
  }, {
65
73
  key: "getMaskLayer",
66
74
  value: function getMaskLayer() {
67
75
  var _this = this;
76
+
68
77
  var _this$parent$getLayer = this.parent.getLayerConfig(),
69
- maskLayers = _this$parent$getLayer.maskLayers;
78
+ maskLayers = _this$parent$getLayer.maskLayers;
79
+
70
80
  var layers = [];
71
81
  maskLayers === null || maskLayers === void 0 ? void 0 : maskLayers.forEach(function (layer) {
72
82
  if (!layer.tileLayer) {
@@ -74,9 +84,11 @@ var Tile = /*#__PURE__*/function () {
74
84
  layers.push(layer);
75
85
  return layer;
76
86
  }
87
+
77
88
  var tileLayer = layer.tileLayer;
78
89
  var tile = tileLayer.getTile(_this.sourceTile.key);
79
90
  var l = tile === null || tile === void 0 ? void 0 : tile.getLayers()[0];
91
+
80
92
  if (l) {
81
93
  layers.push(l);
82
94
  }
@@ -89,40 +101,48 @@ var Tile = /*#__PURE__*/function () {
89
101
  var _addTileMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
90
102
  var mask, container, mainLayer;
91
103
  return _regeneratorRuntime.wrap(function _callee$(_context) {
92
- while (1) switch (_context.prev = _context.next) {
93
- case 0:
94
- mask = new PolygonLayer({
95
- visible: false,
96
- enablePicking: false
97
- }).source({
98
- type: 'FeatureCollection',
99
- features: [this.sourceTile.bboxPolygon]
100
- }, {
101
- parser: {
102
- type: 'geojson',
103
- featureId: 'id'
104
+ while (1) {
105
+ switch (_context.prev = _context.next) {
106
+ case 0:
107
+ mask = new PolygonLayer({
108
+ visible: false,
109
+ enablePicking: false
110
+ }).source({
111
+ type: 'FeatureCollection',
112
+ features: [this.sourceTile.bboxPolygon]
113
+ }, {
114
+ parser: {
115
+ type: 'geojson',
116
+ featureId: 'id'
117
+ }
118
+ }).shape('fill');
119
+ container = createLayerContainer(this.parent.sceneContainer);
120
+ mask.setContainer(container, this.parent.sceneContainer);
121
+ _context.next = 5;
122
+ return mask.init();
123
+
124
+ case 5:
125
+ this.tileMask = mask;
126
+ mainLayer = this.getMainLayer();
127
+
128
+ if (mainLayer !== undefined) {
129
+ mainLayer.tileMask = mask;
104
130
  }
105
- }).shape('fill');
106
- container = createLayerContainer(this.parent.sceneContainer);
107
- mask.setContainer(container, this.parent.sceneContainer);
108
- _context.next = 5;
109
- return mask.init();
110
- case 5:
111
- this.tileMask = mask;
112
- mainLayer = this.getMainLayer();
113
- if (mainLayer !== undefined) {
114
- mainLayer.tileMask = mask;
115
- }
116
- return _context.abrupt("return", mask);
117
- case 9:
118
- case "end":
119
- return _context.stop();
131
+
132
+ return _context.abrupt("return", mask);
133
+
134
+ case 9:
135
+ case "end":
136
+ return _context.stop();
137
+ }
120
138
  }
121
139
  }, _callee, this);
122
140
  }));
141
+
123
142
  function addTileMask() {
124
143
  return _addTileMask.apply(this, arguments);
125
144
  }
145
+
126
146
  return addTileMask;
127
147
  }()
128
148
  }, {
@@ -131,24 +151,30 @@ var Tile = /*#__PURE__*/function () {
131
151
  var _addMask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(layer, mask) {
132
152
  var container;
133
153
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
134
- while (1) switch (_context2.prev = _context2.next) {
135
- case 0:
136
- container = createLayerContainer(this.parent.sceneContainer);
137
- mask.setContainer(container, this.parent.sceneContainer);
138
- _context2.next = 4;
139
- return mask.init();
140
- case 4:
141
- layer.addMask(mask);
142
- this.tileMaskLayers.push(mask);
143
- case 6:
144
- case "end":
145
- return _context2.stop();
154
+ while (1) {
155
+ switch (_context2.prev = _context2.next) {
156
+ case 0:
157
+ container = createLayerContainer(this.parent.sceneContainer);
158
+ mask.setContainer(container, this.parent.sceneContainer);
159
+ _context2.next = 4;
160
+ return mask.init();
161
+
162
+ case 4:
163
+ layer.addMask(mask);
164
+ this.tileMaskLayers.push(mask);
165
+
166
+ case 6:
167
+ case "end":
168
+ return _context2.stop();
169
+ }
146
170
  }
147
171
  }, _callee2, this);
148
172
  }));
173
+
149
174
  function addMask(_x, _x2) {
150
175
  return _addMask.apply(this, arguments);
151
176
  }
177
+
152
178
  return addMask;
153
179
  }()
154
180
  }, {
@@ -157,24 +183,29 @@ var Tile = /*#__PURE__*/function () {
157
183
  var _addLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(layer) {
158
184
  var container;
159
185
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
160
- while (1) switch (_context3.prev = _context3.next) {
161
- case 0:
162
- // set flag
163
- layer.isTileLayer = true;
164
- container = createLayerContainer(this.parent.sceneContainer);
165
- layer.setContainer(container, this.parent.sceneContainer);
166
- this.layers.push(layer);
167
- _context3.next = 6;
168
- return layer.init();
169
- case 6:
170
- case "end":
171
- return _context3.stop();
186
+ while (1) {
187
+ switch (_context3.prev = _context3.next) {
188
+ case 0:
189
+ // set flag
190
+ layer.isTileLayer = true;
191
+ container = createLayerContainer(this.parent.sceneContainer);
192
+ layer.setContainer(container, this.parent.sceneContainer);
193
+ this.layers.push(layer);
194
+ _context3.next = 6;
195
+ return layer.init();
196
+
197
+ case 6:
198
+ case "end":
199
+ return _context3.stop();
200
+ }
172
201
  }
173
202
  }, _callee3, this);
174
203
  }));
204
+
175
205
  function addLayer(_x3) {
176
206
  return _addLayer.apply(this, arguments);
177
207
  }
208
+
178
209
  return addLayer;
179
210
  }()
180
211
  }, {
@@ -190,10 +221,10 @@ var Tile = /*#__PURE__*/function () {
190
221
  l.updateLayerConfig(_defineProperty({}, key, value));
191
222
  });
192
223
  }
193
-
194
224
  /**
195
225
  * 一个 Tile 可能有多个 layer,但是在发生拾取、点击事件的时候只有一个生效
196
226
  */
227
+
197
228
  }, {
198
229
  key: "getMainLayer",
199
230
  value: function getMainLayer() {
@@ -204,12 +235,12 @@ var Tile = /*#__PURE__*/function () {
204
235
  value: function getFeatures(sourceLayer) {
205
236
  return [];
206
237
  }
207
-
208
238
  /**
209
239
  * 在一个 Tile 中可能存在一个相同 ID 的 feature
210
240
  * @param id
211
241
  * @returns
212
242
  */
243
+
213
244
  }, {
214
245
  key: "getFeatureById",
215
246
  value: function getFeatureById(id) {
@@ -219,12 +250,15 @@ var Tile = /*#__PURE__*/function () {
219
250
  key: "destroy",
220
251
  value: function destroy() {
221
252
  var _this$tileMask;
253
+
222
254
  (_this$tileMask = this.tileMask) === null || _this$tileMask === void 0 ? void 0 : _this$tileMask.destroy();
223
255
  this.layers.forEach(function (layer) {
224
256
  return layer.destroy();
225
257
  });
226
258
  }
227
259
  }]);
260
+
228
261
  return Tile;
229
262
  }();
263
+
230
264
  export { Tile as default };
@@ -6,75 +6,98 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+
9
10
  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); }; }
11
+
10
12
  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; } }
13
+
11
14
  import Tile from "./Tile";
12
15
  import { getTileLayer } from "./util";
16
+
13
17
  var VectorTile = /*#__PURE__*/function (_Tile) {
14
18
  _inherits(VectorTile, _Tile);
19
+
15
20
  var _super = _createSuper(VectorTile);
21
+
16
22
  function VectorTile() {
17
23
  _classCallCheck(this, VectorTile);
24
+
18
25
  return _super.apply(this, arguments);
19
26
  }
27
+
20
28
  _createClass(VectorTile, [{
21
29
  key: "initTileLayer",
22
30
  value: function () {
23
31
  var _initTileLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
24
32
  var attributes, layerOptions, vectorLayer, sourceOptions, layer;
25
33
  return _regeneratorRuntime.wrap(function _callee$(_context) {
26
- while (1) switch (_context.prev = _context.next) {
27
- case 0:
28
- attributes = this.parent.getLayerAttributeConfig();
29
- layerOptions = this.getLayerOptions();
30
- vectorLayer = getTileLayer(this.parent.type);
31
- sourceOptions = this.getSourceOption();
32
- if (sourceOptions) {
33
- _context.next = 7;
34
- break;
35
- }
36
- this.isLoaded = true;
37
- return _context.abrupt("return");
38
- case 7:
39
- layer = new vectorLayer(_objectSpread({}, layerOptions)).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
40
- Object.keys(attributes).forEach(function (type) {
41
- var _attributes$attr, _attributes$attr2;
42
- var attr = type;
43
- // @ts-ignore
44
- 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);
45
- });
46
- _context.next = 11;
47
- return this.addLayer(layer);
48
- case 11:
49
- if (!layerOptions.tileMask) {
34
+ while (1) {
35
+ switch (_context.prev = _context.next) {
36
+ case 0:
37
+ attributes = this.parent.getLayerAttributeConfig();
38
+ layerOptions = this.getLayerOptions();
39
+ vectorLayer = getTileLayer(this.parent.type);
40
+ sourceOptions = this.getSourceOption();
41
+
42
+ if (sourceOptions) {
43
+ _context.next = 7;
44
+ break;
45
+ }
46
+
47
+ this.isLoaded = true;
48
+ return _context.abrupt("return");
49
+
50
+ case 7:
51
+ layer = new vectorLayer(_objectSpread({}, layerOptions)).source(sourceOptions.data, sourceOptions.options); // 初始化数据映射
52
+
53
+ Object.keys(attributes).forEach(function (type) {
54
+ var _attributes$attr, _attributes$attr2;
55
+
56
+ var attr = type; // @ts-ignore
57
+
58
+ 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);
59
+ });
60
+ _context.next = 11;
61
+ return this.addLayer(layer);
62
+
63
+ case 11:
64
+ if (!layerOptions.tileMask) {
65
+ _context.next = 14;
66
+ break;
67
+ }
68
+
50
69
  _context.next = 14;
51
- break;
52
- }
53
- _context.next = 14;
54
- return this.addTileMask();
55
- case 14:
56
- this.setLayerMinMaxZoom(layer);
57
- this.isLoaded = true;
58
- case 16:
59
- case "end":
60
- return _context.stop();
70
+ return this.addTileMask();
71
+
72
+ case 14:
73
+ this.setLayerMinMaxZoom(layer);
74
+ this.isLoaded = true;
75
+
76
+ case 16:
77
+ case "end":
78
+ return _context.stop();
79
+ }
61
80
  }
62
81
  }, _callee, this);
63
82
  }));
83
+
64
84
  function initTileLayer() {
65
85
  return _initTileLayer.apply(this, arguments);
66
86
  }
87
+
67
88
  return initTileLayer;
68
89
  }()
69
90
  }, {
70
91
  key: "getSourceOption",
71
92
  value: function getSourceOption() {
72
93
  var rawSource = this.parent.getSource();
94
+
73
95
  var _this$parent$getLayer = this.parent.getLayerConfig(),
74
- _this$parent$getLayer2 = _this$parent$getLayer.sourceLayer,
75
- sourceLayer = _this$parent$getLayer2 === void 0 ? 'defaultLayer' : _this$parent$getLayer2,
76
- _this$parent$getLayer3 = _this$parent$getLayer.featureId,
77
- featureId = _this$parent$getLayer3 === void 0 ? 'id' : _this$parent$getLayer3;
96
+ _this$parent$getLayer2 = _this$parent$getLayer.sourceLayer,
97
+ sourceLayer = _this$parent$getLayer2 === void 0 ? 'defaultLayer' : _this$parent$getLayer2,
98
+ _this$parent$getLayer3 = _this$parent$getLayer.featureId,
99
+ featureId = _this$parent$getLayer3 === void 0 ? 'id' : _this$parent$getLayer3;
100
+
78
101
  var features = this.getFeatures(sourceLayer);
79
102
  return {
80
103
  data: {
@@ -100,33 +123,37 @@ var VectorTile = /*#__PURE__*/function (_Tile) {
100
123
  minZoom: this.z - 1
101
124
  });
102
125
  }
103
- }
104
- // 获取瓦片数据
126
+ } // 获取瓦片数据
127
+
105
128
  }, {
106
129
  key: "getFeatures",
107
130
  value: function getFeatures(sourceLayer) {
108
131
  var source = this.sourceTile.data;
109
132
  return source.getTileData(sourceLayer);
110
133
  }
111
-
112
134
  /**
113
135
  * 在一个 Tile 中可能存在一个相同 ID 的 feature
114
136
  * @param id
115
137
  * @returns
116
138
  */
139
+
117
140
  }, {
118
141
  key: "getFeatureById",
119
142
  value: function getFeatureById(id) {
120
143
  var layer = this.getMainLayer();
144
+
121
145
  if (!layer) {
122
146
  return [];
123
147
  }
148
+
124
149
  var res = layer.getSource().data.dataArray.filter(function (d) {
125
150
  return d._id === id;
126
151
  });
127
152
  return res;
128
153
  }
129
154
  }]);
155
+
130
156
  return VectorTile;
131
157
  }(Tile);
158
+
132
159
  export { VectorTile as default };
@@ -8,32 +8,43 @@ import RasterTile from "./RasterTile";
8
8
  import VectorTile from "./VectorTile";
9
9
  export function getTileFactory(layer) {
10
10
  var tileType = layer.type;
11
+
11
12
  switch (tileType) {
12
13
  case 'PolygonLayer':
13
14
  return VectorTile;
15
+
14
16
  case 'LineLayer':
15
17
  return VectorTile;
18
+
16
19
  case 'PointLayer':
17
20
  return VectorTile;
21
+
18
22
  case 'TileDebugLayer':
19
23
  return DebugTile;
24
+
20
25
  case 'MaskLayer':
21
26
  return MaskLayer;
27
+
22
28
  case 'RasterLayer':
23
29
  var dataType = layer.getSource().parser.dataType;
30
+
24
31
  switch (dataType) {
25
32
  case RasterTileType.RGB:
26
33
  case RasterTileType.CUSTOMRGB:
27
34
  return RasterRGBTile;
35
+
28
36
  case RasterTileType.ARRAYBUFFER:
29
37
  case RasterTileType.CUSTOMARRAYBUFFER:
30
38
  return RasterTile;
39
+
31
40
  case RasterTileType.TERRAINRGB:
32
41
  case RasterTileType.CUSTOMTERRAINRGB:
33
42
  return RasterTerrainRGBTile;
43
+
34
44
  default:
35
45
  return ImageTile;
36
46
  }
47
+
37
48
  default:
38
49
  return VectorTile;
39
50
  }