@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
@@ -6,7 +6,9 @@ import _createClass from "@babel/runtime/helpers/esm/createClass";
6
6
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
7
  import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
8
8
  import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWarningHelper";
9
+
9
10
  var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
11
+
10
12
  import _regeneratorRuntime from "@babel/runtime/regenerator";
11
13
  import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
12
14
  import { Version } from '@antv/l7-maps';
@@ -17,27 +19,35 @@ import 'reflect-metadata';
17
19
  var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService), _dec3 = inject(TYPES.IFontService), _dec(_class = (_class2 = /*#__PURE__*/function () {
18
20
  function DataMappingPlugin() {
19
21
  _classCallCheck(this, DataMappingPlugin);
22
+
20
23
  _initializerDefineProperty(this, "mapService", _descriptor, this);
24
+
21
25
  _initializerDefineProperty(this, "fontService", _descriptor2, this);
22
26
  }
27
+
23
28
  _createClass(DataMappingPlugin, [{
24
29
  key: "apply",
25
30
  value: function apply(layer, _ref) {
26
31
  var _this = this;
32
+
27
33
  var styleAttributeService = _ref.styleAttributeService;
28
34
  layer.hooks.init.tapPromise('DataMappingPlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
29
35
  return _regeneratorRuntime.wrap(function _callee$(_context) {
30
- while (1) switch (_context.prev = _context.next) {
31
- case 0:
32
- layer.log(IDebugLog.MappingStart, ILayerStage.INIT);
33
- // 初始化重新生成 map
34
- _this.generateMaping(layer, {
35
- styleAttributeService: styleAttributeService
36
- });
37
- layer.log(IDebugLog.MappingEnd, ILayerStage.INIT);
38
- case 3:
39
- case "end":
40
- return _context.stop();
36
+ while (1) {
37
+ switch (_context.prev = _context.next) {
38
+ case 0:
39
+ layer.log(IDebugLog.MappingStart, ILayerStage.INIT); // 初始化重新生成 map
40
+
41
+ _this.generateMaping(layer, {
42
+ styleAttributeService: styleAttributeService
43
+ });
44
+
45
+ layer.log(IDebugLog.MappingEnd, ILayerStage.INIT);
46
+
47
+ case 3:
48
+ case "end":
49
+ return _context.stop();
50
+ }
41
51
  }
42
52
  }, _callee);
43
53
  })));
@@ -45,93 +55,104 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
45
55
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
46
56
  var mappingResult;
47
57
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
48
- while (1) switch (_context2.prev = _context2.next) {
49
- case 0:
50
- if (flag) {
51
- _context2.next = 2;
52
- break;
53
- }
54
- return _context2.abrupt("return", flag);
55
- case 2:
56
- layer.dataState.dataMappingNeedUpdate = false;
57
- layer.log(IDebugLog.MappingStart, ILayerStage.UPDATE);
58
- mappingResult = _this.generateMaping(layer, {
59
- styleAttributeService: styleAttributeService
60
- });
61
- layer.log(IDebugLog.MappingEnd, ILayerStage.UPDATE);
62
- return _context2.abrupt("return", mappingResult);
63
- case 7:
64
- case "end":
65
- return _context2.stop();
58
+ while (1) {
59
+ switch (_context2.prev = _context2.next) {
60
+ case 0:
61
+ if (flag) {
62
+ _context2.next = 2;
63
+ break;
64
+ }
65
+
66
+ return _context2.abrupt("return", flag);
67
+
68
+ case 2:
69
+ layer.dataState.dataMappingNeedUpdate = false;
70
+ layer.log(IDebugLog.MappingStart, ILayerStage.UPDATE);
71
+ mappingResult = _this.generateMaping(layer, {
72
+ styleAttributeService: styleAttributeService
73
+ });
74
+ layer.log(IDebugLog.MappingEnd, ILayerStage.UPDATE);
75
+ return _context2.abrupt("return", mappingResult);
76
+
77
+ case 7:
78
+ case "end":
79
+ return _context2.stop();
80
+ }
66
81
  }
67
82
  }, _callee2);
68
83
  }));
84
+
69
85
  return function (_x) {
70
86
  return _ref3.apply(this, arguments);
71
87
  };
72
- }());
88
+ }()); // remapping before render
73
89
 
74
- // remapping before render
75
90
  layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
76
91
  var source = layer.getSource();
92
+
77
93
  if (layer.layerModelNeedUpdate || !source || !source.inited) {
78
94
  return;
79
95
  }
96
+
80
97
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
81
98
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
82
- var dataArray = source.data.dataArray;
83
- // TODO 数据为空的情况
99
+ var dataArray = source.data.dataArray; // TODO 数据为空的情况
100
+
84
101
  if (Array.isArray(dataArray) && dataArray.length === 0) {
85
102
  return;
86
103
  }
104
+
87
105
  var attributesToRemapping = attributes.filter(function (attribute) {
88
106
  return attribute.needRemapping;
89
107
  } // 如果filter变化
90
108
  );
109
+ var filterData = dataArray; // 数据过滤完 再执行数据映射
91
110
 
92
- var filterData = dataArray;
93
- // 数据过滤完 再执行数据映射
94
111
  if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
95
112
  filterData = dataArray.filter(function (record) {
96
113
  return _this.applyAttributeMapping(filter, record)[0];
97
114
  });
98
115
  }
116
+
99
117
  if (attributesToRemapping.length) {
100
118
  // 过滤数据
101
119
  var encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
102
- layer.setEncodedData(encodeData);
103
- }
104
120
 
105
- // 处理文本更新,更新文字形状
121
+ layer.setEncodedData(encodeData);
122
+ } // 处理文本更新,更新文字形状
106
123
  // layer.emit('remapping', null);
124
+
107
125
  });
108
126
  }
109
127
  }, {
110
128
  key: "generateMaping",
111
129
  value: function generateMaping(layer, _ref4) {
112
130
  var _this2 = this;
131
+
113
132
  var styleAttributeService = _ref4.styleAttributeService;
114
133
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
115
134
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
116
135
  var dataArray = layer.getSource().data.dataArray;
117
- var filterData = dataArray;
118
- // 数据过滤完 再执行数据映射
136
+ var filterData = dataArray; // 数据过滤完 再执行数据映射
137
+
119
138
  if (filter !== null && filter !== void 0 && filter.scale) {
120
139
  filterData = dataArray.filter(function (record) {
121
140
  return _this2.applyAttributeMapping(filter, record)[0];
122
141
  });
123
- }
124
- // Tip: layer 对数据做处理
142
+ } // Tip: layer 对数据做处理
125
143
  // 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
126
144
  // 在各个 layer 中继承
127
145
 
146
+
128
147
  filterData = layer.processData(filterData);
129
148
  var encodeData = this.mapping(layer, attributes, filterData, undefined);
130
149
  layer.setEncodedData(encodeData);
150
+
131
151
  if (dataArray.length === 0 && layer.encodeDataLength === 0) {
132
152
  return false;
133
- }
134
- // 对外暴露事件
153
+ } // 对外暴露事件
154
+
155
+
135
156
  layer.emit('dataUpdate', null);
136
157
  return true;
137
158
  }
@@ -139,11 +160,13 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
139
160
  key: "mapping",
140
161
  value: function mapping(layer, attributes, data, predata) {
141
162
  var _this3 = this;
163
+
142
164
  var _ref5 = layer.getLayerConfig(),
143
- _ref5$arrow = _ref5.arrow,
144
- arrow = _ref5$arrow === void 0 ? {
145
- enable: false
146
- } : _ref5$arrow;
165
+ _ref5$arrow = _ref5.arrow,
166
+ arrow = _ref5$arrow === void 0 ? {
167
+ enable: false
168
+ } : _ref5$arrow;
169
+
147
170
  var usedAttributes = attributes.filter(function (attribute) {
148
171
  return attribute.scale !== undefined;
149
172
  }).filter(function (attribute) {
@@ -151,47 +174,52 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
151
174
  });
152
175
  var mappedData = data.map(function (record, i) {
153
176
  var preRecord = predata ? predata[i] : {};
177
+
154
178
  var encodeRecord = _objectSpread({
155
179
  id: record._id,
156
180
  coordinates: record.coordinates
157
181
  }, preRecord);
182
+
158
183
  usedAttributes.forEach(function (attribute) {
159
- var values = _this3.applyAttributeMapping(attribute, record);
160
- // TODO: 支持每个属性配置 postprocess
184
+ var values = _this3.applyAttributeMapping(attribute, record); // TODO: 支持每个属性配置 postprocess
185
+
186
+
161
187
  if (attribute.name === 'color') {
162
188
  values = values.map(function (c) {
163
189
  return rgb2arr(c);
164
190
  });
165
- }
166
- // @ts-ignore
167
- encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values;
191
+ } // @ts-ignore
192
+
193
+
194
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
168
195
 
169
- // 增加对 layer/text/iconfont unicode 映射的解析
170
196
  if (attribute.name === 'shape') {
171
197
  encodeRecord.shape = _this3.fontService.getIconFontKey(encodeRecord[attribute.name]);
172
198
  }
173
199
  });
200
+
174
201
  if (arrow.enable && (encodeRecord.shape === 'line' || encodeRecord.shape === 'halfLine')) {
175
202
  // 只有在线图层且支持配置箭头的时候进行插入顶点的处理
176
- var coords = encodeRecord.coordinates;
177
- // @ts-ignore
203
+ var coords = encodeRecord.coordinates; // @ts-ignore
204
+
178
205
  if (layer.arrowInsertCount < layer.encodeDataLength) {
179
206
  // Tip: arrowInsert 的判断用于确保每一条线数据 arrow 的属性点只会被植入一次
180
207
  var arrowPoint = _this3.getArrowPoints(coords[0], coords[1]);
181
- encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint);
182
- // @ts-ignore
208
+
209
+ encodeRecord.coordinates.splice(1, 0, arrowPoint, arrowPoint); // @ts-ignore
210
+
183
211
  layer.arrowInsertCount++;
184
212
  }
185
213
  }
214
+
186
215
  return encodeRecord;
187
216
  });
188
217
  attributes.forEach(function (attribute) {
189
218
  attribute.needRemapping = false;
190
- });
191
- // 调整数据兼容 Amap2.0
192
- this.adjustData2Amap2Coordinates(mappedData, layer);
219
+ }); // 调整数据兼容 Amap2.0
220
+
221
+ this.adjustData2Amap2Coordinates(mappedData, layer); // 调整数据兼容 SimpleCoordinates
193
222
 
194
- // 调整数据兼容 SimpleCoordinates
195
223
  this.adjustData2SimpleCoordinates(mappedData);
196
224
  return mappedData;
197
225
  }
@@ -199,36 +227,38 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
199
227
  key: "adjustData2Amap2Coordinates",
200
228
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
201
229
  var _this4 = this;
230
+
202
231
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
203
232
  if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
204
233
  var layerCenter = layer.coordCenter || layer.getSource().center;
234
+
205
235
  if (typeof mappedData[0].coordinates[0] === 'number') {
206
236
  // 单个的点数据
207
237
  // @ts-ignore
208
- mappedData
209
- // TODO: 避免经纬度被重复计算导致坐标位置偏移
238
+ mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
210
239
  .filter(function (d) {
211
240
  return !d.originCoordinates;
212
241
  }).map(function (d) {
213
- d.version = Version['GAODE2.x'];
214
- // @ts-ignore
242
+ d.version = Version['GAODE2.x']; // @ts-ignore
243
+
215
244
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
216
245
  // @ts-ignore
217
246
  // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
247
+
218
248
  d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
219
249
  });
220
250
  } else {
221
251
  // 连续的线、面数据
222
- mappedData
223
- // TODO: 避免经纬度被重复计算导致坐标位置偏移
252
+ mappedData // TODO: 避免经纬度被重复计算导致坐标位置偏移
224
253
  .filter(function (d) {
225
254
  return !d.originCoordinates;
226
255
  }).map(function (d) {
227
- d.version = Version['GAODE2.x'];
228
- // @ts-ignore
256
+ d.version = Version['GAODE2.x']; // @ts-ignore
257
+
229
258
  d.originCoordinates = cloneDeep(d.coordinates); // 为了兼容高德1.x 需要保存一份原始的经纬度坐标数据(许多上层逻辑依赖经纬度数据)
230
259
  // @ts-ignore
231
260
  // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
261
+
232
262
  d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
233
263
  });
234
264
  }
@@ -238,6 +268,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
238
268
  key: "adjustData2SimpleCoordinates",
239
269
  value: function adjustData2SimpleCoordinates(mappedData) {
240
270
  var _this5 = this;
271
+
241
272
  if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
242
273
  mappedData.map(function (d) {
243
274
  if (!d.simpleCoordinate) {
@@ -251,9 +282,11 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
251
282
  key: "unProjectCoordinates",
252
283
  value: function unProjectCoordinates(coordinates) {
253
284
  var _this6 = this;
285
+
254
286
  if (typeof coordinates[0] === 'number') {
255
287
  return this.mapService.simpleMapCoord.unproject(coordinates);
256
288
  }
289
+
257
290
  if (coordinates[0] && coordinates[0][0] instanceof Array) {
258
291
  // @ts-ignore
259
292
  var coords = [];
@@ -262,20 +295,20 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
262
295
  var c1 = [];
263
296
  coord.map(function (co) {
264
297
  c1.push(_this6.mapService.simpleMapCoord.unproject(co));
265
- });
266
- // @ts-ignore
298
+ }); // @ts-ignore
299
+
267
300
  coords.push(c1);
268
- });
269
- // @ts-ignore
301
+ }); // @ts-ignore
302
+
270
303
  return coords;
271
304
  } else {
272
305
  // @ts-ignore
273
- var _coords = [];
274
- // @ts-ignore
306
+ var _coords = []; // @ts-ignore
307
+
275
308
  coordinates.map(function (coord) {
276
309
  _coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
277
- });
278
- // @ts-ignore
310
+ }); // @ts-ignore
311
+
279
312
  return _coords;
280
313
  }
281
314
  }
@@ -283,22 +316,25 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
283
316
  key: "applyAttributeMapping",
284
317
  value: function applyAttributeMapping(attribute, record) {
285
318
  var _attribute$scale;
319
+
286
320
  if (!attribute.scale) {
287
321
  return [];
288
322
  }
323
+
289
324
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
290
325
  var params = [];
291
326
  scalers.forEach(function (_ref6) {
292
327
  var _attribute$scale2;
328
+
293
329
  var field = _ref6.field;
330
+
294
331
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
295
332
  // TODO:多字段,常量
296
333
  params.push(record[field]);
297
334
  }
298
335
  });
299
336
  var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
300
- return mappingResult;
301
- // return attribute.mapping ? attribute.mapping(params) : [];
337
+ return mappingResult; // return attribute.mapping ? attribute.mapping(params) : [];
302
338
  }
303
339
  }, {
304
340
  key: "getArrowPoints",
@@ -309,6 +345,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
309
345
  return arrowPoint;
310
346
  }
311
347
  }]);
348
+
312
349
  return DataMappingPlugin;
313
350
  }(), (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "mapService", [_dec2], {
314
351
  configurable: true,
@@ -1,7 +1,9 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
2
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
3
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
+
4
5
  var _dec, _class;
6
+
5
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
6
8
  import { IDebugLog, ILayerStage, TYPES } from '@antv/l7-core';
7
9
  import Source from '@antv/l7-source';
@@ -11,64 +13,79 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
11
13
  function DataSourcePlugin() {
12
14
  _classCallCheck(this, DataSourcePlugin);
13
15
  }
16
+
14
17
  _createClass(DataSourcePlugin, [{
15
18
  key: "apply",
16
19
  value: function apply(layer) {
17
20
  var _this = this;
21
+
18
22
  this.mapService = layer.getContainer().get(TYPES.IMapService);
19
23
  layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
20
24
  var source, _ref2, data, options;
25
+
21
26
  return _regeneratorRuntime.wrap(function _callee$(_context) {
22
- while (1) switch (_context.prev = _context.next) {
23
- case 0:
24
- layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
25
- source = layer.getSource();
26
- if (!source) {
27
- // Tip: 用户没有传入 source 的时候使用图层的默认数据
28
- _ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
29
- source = new Source(data, options);
30
- layer.setSource(source);
31
- }
32
- if (!source.inited) {
33
- _context.next = 8;
27
+ while (1) {
28
+ switch (_context.prev = _context.next) {
29
+ case 0:
30
+ layer.log(IDebugLog.SourceInitStart, ILayerStage.INIT);
31
+ source = layer.getSource();
32
+
33
+ if (!source) {
34
+ // Tip: 用户没有传入 source 的时候使用图层的默认数据
35
+ _ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
36
+ source = new Source(data, options);
37
+ layer.setSource(source);
38
+ }
39
+
40
+ if (!source.inited) {
41
+ _context.next = 8;
42
+ break;
43
+ }
44
+
45
+ _this.updateClusterData(layer);
46
+
47
+ layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
48
+ _context.next = 10;
34
49
  break;
35
- }
36
- _this.updateClusterData(layer);
37
- layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
38
- _context.next = 10;
39
- break;
40
- case 8:
41
- _context.next = 10;
42
- return new Promise(function (resolve) {
43
- source.on('update', function (e) {
44
- if (e.type === 'inited') {
45
- _this.updateClusterData(layer);
46
- layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
47
- }
48
- resolve(null);
50
+
51
+ case 8:
52
+ _context.next = 10;
53
+ return new Promise(function (resolve) {
54
+ source.on('update', function (e) {
55
+ if (e.type === 'inited') {
56
+ _this.updateClusterData(layer);
57
+
58
+ layer.log(IDebugLog.SourceInitEnd, ILayerStage.INIT);
59
+ }
60
+
61
+ resolve(null);
62
+ });
49
63
  });
50
- });
51
- case 10:
52
- case "end":
53
- return _context.stop();
64
+
65
+ case 10:
66
+ case "end":
67
+ return _context.stop();
68
+ }
54
69
  }
55
70
  }, _callee);
56
- })));
71
+ }))); // 检测数据是否需要更新
57
72
 
58
- // 检测数据是否需要更新
59
73
  layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
60
74
  var neeUpdateCluster, dataSourceNeedUpdate, needScale;
61
75
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
62
- while (1) switch (_context2.prev = _context2.next) {
63
- case 0:
64
- neeUpdateCluster = _this.updateClusterData(layer);
65
- dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
66
- layer.dataState.dataSourceNeedUpdate = false;
67
- needScale = neeUpdateCluster || dataSourceNeedUpdate;
68
- return _context2.abrupt("return", needScale);
69
- case 5:
70
- case "end":
71
- return _context2.stop();
76
+ while (1) {
77
+ switch (_context2.prev = _context2.next) {
78
+ case 0:
79
+ neeUpdateCluster = _this.updateClusterData(layer);
80
+ dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
81
+ layer.dataState.dataSourceNeedUpdate = false;
82
+ needScale = neeUpdateCluster || dataSourceNeedUpdate;
83
+ return _context2.abrupt("return", needScale);
84
+
85
+ case 5:
86
+ case "end":
87
+ return _context2.stop();
88
+ }
72
89
  }
73
90
  }, _callee2);
74
91
  })));
@@ -80,27 +97,33 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
80
97
  if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
81
98
  return false;
82
99
  }
100
+
83
101
  var source = layer.getSource();
84
102
  var cluster = source.cluster;
85
103
  var _source$clusterOption = source.clusterOptions.zoom,
86
- zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
104
+ zoom = _source$clusterOption === void 0 ? 0 : _source$clusterOption;
87
105
  var newZoom = this.mapService.getZoom() - 1;
88
106
  var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
107
+
89
108
  if (cluster && dataSourceNeedUpdate) {
90
109
  // 数据发生更新
91
110
  source.updateClusterData(Math.floor(newZoom));
92
- }
93
- // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
111
+ } // 如果 dataSource 有更新,跳过 zoom 的判断,直接更新一次
112
+
113
+
94
114
  if (cluster && Math.abs(layer.clusterZoom - newZoom) >= 1) {
95
115
  if (zoom !== Math.floor(newZoom)) {
96
116
  source.updateClusterData(Math.floor(newZoom));
97
117
  }
118
+
98
119
  layer.clusterZoom = newZoom;
99
120
  return true;
100
121
  }
122
+
101
123
  return false;
102
124
  }
103
125
  }]);
126
+
104
127
  return DataSourcePlugin;
105
128
  }()) || _class);
106
129
  export { DataSourcePlugin as default };