@antv/l7-layers 2.15.1 → 2.15.3

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