@antv/l7-layers 2.10.3 → 2.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (362) hide show
  1. package/es/Geometry/index.d.ts +3 -2
  2. package/es/Geometry/index.js +17 -27
  3. package/es/Geometry/models/billboard.d.ts +2 -2
  4. package/es/Geometry/models/billboard.js +37 -77
  5. package/es/Geometry/models/plane.d.ts +2 -2
  6. package/es/Geometry/models/plane.js +40 -80
  7. package/es/Geometry/models/sprite.d.ts +2 -2
  8. package/es/Geometry/models/sprite.js +45 -83
  9. package/es/canvas/index.d.ts +3 -2
  10. package/es/canvas/index.js +19 -29
  11. package/es/canvas/models/canvas.d.ts +2 -2
  12. package/es/canvas/models/canvas.js +15 -54
  13. package/es/citybuliding/building.d.ts +3 -2
  14. package/es/citybuliding/building.js +17 -26
  15. package/es/citybuliding/models/build.d.ts +2 -2
  16. package/es/citybuliding/models/build.js +25 -70
  17. package/es/core/BaseLayer.d.ts +18 -21
  18. package/es/core/BaseLayer.js +274 -385
  19. package/es/core/BaseModel.d.ts +2 -2
  20. package/es/core/BaseModel.js +6 -47
  21. package/es/core/triangulation.js +1 -8
  22. package/es/earth/index.d.ts +2 -2
  23. package/es/earth/index.js +9 -28
  24. package/es/earth/models/atmosphere.d.ts +2 -2
  25. package/es/earth/models/atmosphere.js +22 -67
  26. package/es/earth/models/base.d.ts +2 -2
  27. package/es/earth/models/base.js +43 -89
  28. package/es/earth/models/bloomsphere.d.ts +2 -2
  29. package/es/earth/models/bloomsphere.js +22 -67
  30. package/es/heatmap/index.d.ts +3 -2
  31. package/es/heatmap/index.js +22 -33
  32. package/es/heatmap/models/grid.d.ts +2 -2
  33. package/es/heatmap/models/grid.js +27 -68
  34. package/es/heatmap/models/grid3d.d.ts +2 -2
  35. package/es/heatmap/models/grid3d.js +28 -69
  36. package/es/heatmap/models/heatmap.d.ts +2 -2
  37. package/es/heatmap/models/heatmap.js +14 -40
  38. package/es/heatmap/models/hexagon.d.ts +2 -2
  39. package/es/heatmap/models/hexagon.js +28 -69
  40. package/es/image/index.d.ts +3 -2
  41. package/es/image/index.js +17 -27
  42. package/es/image/models/dataImage.d.ts +2 -2
  43. package/es/image/models/dataImage.js +54 -93
  44. package/es/image/models/image.d.ts +2 -2
  45. package/es/image/models/image.js +67 -108
  46. package/es/image/models/tileDataImage.d.ts +2 -2
  47. package/es/image/models/tileDataImage.js +43 -84
  48. package/es/index.d.ts +2 -2
  49. package/es/index.js +2 -2
  50. package/es/line/index.d.ts +4 -5
  51. package/es/line/index.js +25 -51
  52. package/es/line/models/arc.d.ts +2 -2
  53. package/es/line/models/arc.js +38 -73
  54. package/es/line/models/arc_3d.d.ts +2 -2
  55. package/es/line/models/arc_3d.js +34 -69
  56. package/es/line/models/earthArc_3d.d.ts +2 -2
  57. package/es/line/models/earthArc_3d.js +37 -72
  58. package/es/line/models/great_circle.d.ts +2 -2
  59. package/es/line/models/great_circle.js +29 -70
  60. package/es/line/models/half.d.ts +2 -2
  61. package/es/line/models/half.js +17 -40
  62. package/es/line/models/index.d.ts +1 -1
  63. package/es/line/models/index.js +2 -0
  64. package/es/line/models/line.d.ts +2 -2
  65. package/es/line/models/line.js +47 -79
  66. package/es/line/models/linearline.d.ts +2 -2
  67. package/es/line/models/linearline.js +31 -70
  68. package/es/line/models/simpleLine.d.ts +2 -2
  69. package/es/line/models/simpleLine.js +34 -71
  70. package/es/line/models/simpleTileLine.d.ts +2 -2
  71. package/es/line/models/simpleTileLine.js +30 -70
  72. package/es/line/models/tile.d.ts +2 -2
  73. package/es/line/models/tile.js +17 -40
  74. package/es/line/models/wall.d.ts +2 -2
  75. package/es/line/models/wall.js +22 -67
  76. package/es/mask/index.d.ts +4 -2
  77. package/es/mask/index.js +97 -27
  78. package/es/mask/models/fill.d.ts +2 -2
  79. package/es/mask/models/fill.js +16 -40
  80. package/es/mask/models/index.d.ts +1 -1
  81. package/es/mask/models/index.js +3 -1
  82. package/es/plugins/DataMappingPlugin.d.ts +2 -0
  83. package/es/plugins/DataMappingPlugin.js +152 -90
  84. package/es/plugins/DataSourcePlugin.js +30 -74
  85. package/es/plugins/FeatureScalePlugin.d.ts +1 -0
  86. package/es/plugins/FeatureScalePlugin.js +61 -85
  87. package/es/plugins/LayerModelPlugin.d.ts +2 -2
  88. package/es/plugins/LayerModelPlugin.js +37 -121
  89. package/es/plugins/LayerStylePlugin.js +6 -1
  90. package/es/plugins/MultiPassRendererPlugin.js +1 -1
  91. package/es/plugins/PixelPickingPlugin.js +1 -1
  92. package/es/plugins/RegisterStyleAttributePlugin.js +16 -1
  93. package/es/plugins/UpdateModelPlugin.js +0 -3
  94. package/es/plugins/UpdateStyleAttributePlugin.js +6 -3
  95. package/es/point/index.d.ts +4 -4
  96. package/es/point/index.js +23 -55
  97. package/es/point/models/earthExtrude.d.ts +2 -2
  98. package/es/point/models/earthExtrude.js +30 -73
  99. package/es/point/models/earthFill.d.ts +2 -2
  100. package/es/point/models/earthFill.js +21 -66
  101. package/es/point/models/extrude.d.ts +2 -2
  102. package/es/point/models/extrude.js +17 -40
  103. package/es/point/models/fill.d.ts +2 -2
  104. package/es/point/models/fill.js +20 -43
  105. package/es/point/models/fillmage.d.ts +2 -2
  106. package/es/point/models/fillmage.js +43 -82
  107. package/es/point/models/image.d.ts +2 -2
  108. package/es/point/models/image.js +31 -72
  109. package/es/point/models/index.d.ts +1 -1
  110. package/es/point/models/index.js +2 -0
  111. package/es/point/models/normal.d.ts +2 -2
  112. package/es/point/models/normal.js +30 -71
  113. package/es/point/models/radar.d.ts +2 -2
  114. package/es/point/models/radar.js +35 -75
  115. package/es/point/models/simplePoint.d.ts +2 -2
  116. package/es/point/models/simplePoint.js +29 -70
  117. package/es/point/models/text.d.ts +2 -3
  118. package/es/point/models/text.js +110 -183
  119. package/es/point/models/tile.d.ts +2 -2
  120. package/es/point/models/tile.js +35 -77
  121. package/es/point/models/tileText.d.ts +2 -2
  122. package/es/point/models/tileText.js +116 -151
  123. package/es/polygon/index.d.ts +3 -2
  124. package/es/polygon/index.js +24 -27
  125. package/es/polygon/models/extrude.d.ts +2 -2
  126. package/es/polygon/models/extrude.js +32 -69
  127. package/es/polygon/models/fill.d.ts +2 -2
  128. package/es/polygon/models/fill.js +43 -76
  129. package/es/polygon/models/index.d.ts +1 -1
  130. package/es/polygon/models/index.js +2 -0
  131. package/es/polygon/models/ocean.d.ts +2 -2
  132. package/es/polygon/models/ocean.js +28 -69
  133. package/es/polygon/models/tile.d.ts +2 -2
  134. package/es/polygon/models/tile.js +30 -70
  135. package/es/polygon/models/water.d.ts +2 -2
  136. package/es/polygon/models/water.js +28 -69
  137. package/es/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -1
  138. package/es/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +2 -1
  139. package/es/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +2 -1
  140. package/es/raster/index.d.ts +4 -3
  141. package/es/raster/index.js +22 -28
  142. package/es/raster/models/index.d.ts +1 -1
  143. package/es/raster/models/index.js +3 -1
  144. package/es/raster/models/raster.d.ts +2 -2
  145. package/es/raster/models/raster.js +13 -36
  146. package/es/raster/models/rasterRgb.d.ts +2 -2
  147. package/es/raster/models/rasterRgb.js +13 -36
  148. package/es/raster/models/rasterTile.d.ts +2 -2
  149. package/es/raster/models/rasterTile.js +36 -77
  150. package/es/raster/raster.d.ts +1 -1
  151. package/es/raster/raster.js +22 -42
  152. package/es/tile/interaction/TilePickService.d.ts +16 -0
  153. package/es/tile/interaction/TilePickService.js +129 -0
  154. package/es/tile/interaction/getRasterData.d.ts +2 -2
  155. package/es/tile/interaction/utils.js +11 -3
  156. package/es/tile/interface.d.ts +4 -5
  157. package/es/tile/manager/base.d.ts +12 -17
  158. package/es/tile/manager/base.js +47 -212
  159. package/es/tile/manager/layerManager.d.ts +19 -0
  160. package/es/tile/manager/layerManager.js +254 -0
  161. package/es/tile/manager/mapLayerManager.d.ts +7 -0
  162. package/es/tile/manager/mapLayerManager.js +119 -0
  163. package/es/tile/models/tileModel.d.ts +10 -0
  164. package/es/tile/models/tileModel.js +81 -0
  165. package/es/tile/render/TileRenderService.d.ts +10 -0
  166. package/es/tile/render/TileRenderService.js +68 -0
  167. package/es/tile/style/TileStyleService.d.ts +17 -0
  168. package/es/tile/style/TileStyleService.js +118 -0
  169. package/es/tile/style/constants.d.ts +13 -1
  170. package/es/tile/style/constants.js +15 -6
  171. package/es/tile/style/utils.d.ts +8 -1
  172. package/es/tile/style/utils.js +126 -0
  173. package/es/tile/tileFactory/base.d.ts +45 -0
  174. package/es/tile/tileFactory/base.js +403 -0
  175. package/es/tile/tileFactory/index.d.ts +4 -10
  176. package/es/tile/tileFactory/index.js +23 -30
  177. package/es/tile/tileFactory/layers/{RasterDataLayer.d.ts → rasterDataLayer.d.ts} +3 -3
  178. package/es/tile/tileFactory/layers/{RasterDataLayer.js → rasterDataLayer.js} +21 -33
  179. package/es/tile/tileFactory/layers/{TileDebugLayer.d.ts → tileTest.d.ts} +2 -2
  180. package/es/tile/tileFactory/layers/{TileDebugLayer.js → tileTest.js} +10 -23
  181. package/es/tile/tileFactory/layers/vectorLayer.d.ts +30 -0
  182. package/es/tile/tileFactory/layers/vectorLayer.js +253 -0
  183. package/es/tile/tileFactory/line.d.ts +12 -0
  184. package/es/tile/tileFactory/line.js +59 -0
  185. package/es/tile/tileFactory/mask.d.ts +12 -0
  186. package/es/tile/tileFactory/mask.js +60 -0
  187. package/es/tile/tileFactory/point.d.ts +12 -0
  188. package/es/tile/tileFactory/point.js +60 -0
  189. package/es/tile/tileFactory/polygon.d.ts +12 -0
  190. package/es/tile/tileFactory/polygon.js +59 -0
  191. package/es/tile/tileFactory/raster.d.ts +12 -0
  192. package/es/tile/tileFactory/raster.js +55 -0
  193. package/es/tile/tileFactory/rasterData.d.ts +12 -0
  194. package/es/tile/tileFactory/rasterData.js +81 -0
  195. package/es/tile/tileFactory/test.d.ts +12 -0
  196. package/es/tile/tileFactory/test.js +94 -0
  197. package/es/tile/tileLayer/MapTileLayer.d.ts +6 -0
  198. package/es/tile/tileLayer/MapTileLayer.js +48 -0
  199. package/es/tile/tileLayer/TileLayer.d.ts +22 -0
  200. package/es/tile/tileLayer/TileLayer.js +198 -0
  201. package/es/tile/tileLayer/base.d.ts +33 -0
  202. package/es/tile/tileLayer/base.js +212 -0
  203. package/es/tile/utils.d.ts +11 -1
  204. package/es/tile/utils.js +129 -0
  205. package/es/utils/dataMappingStyle.d.ts +4 -4
  206. package/es/utils/dataMappingStyle.js +18 -16
  207. package/es/utils/layerData.js +11 -5
  208. package/es/wind/index.d.ts +3 -2
  209. package/es/wind/index.js +17 -27
  210. package/es/wind/models/wind.d.ts +2 -2
  211. package/es/wind/models/wind.js +104 -123
  212. package/lib/Geometry/index.js +17 -29
  213. package/lib/Geometry/models/billboard.js +37 -79
  214. package/lib/Geometry/models/plane.js +40 -82
  215. package/lib/Geometry/models/sprite.js +45 -85
  216. package/lib/canvas/index.js +19 -31
  217. package/lib/canvas/models/canvas.js +15 -56
  218. package/lib/citybuliding/building.js +17 -28
  219. package/lib/citybuliding/models/build.js +25 -72
  220. package/lib/core/BaseLayer.js +269 -385
  221. package/lib/core/BaseModel.js +6 -48
  222. package/lib/core/triangulation.js +1 -8
  223. package/lib/earth/index.js +9 -30
  224. package/lib/earth/models/atmosphere.js +22 -69
  225. package/lib/earth/models/base.js +42 -90
  226. package/lib/earth/models/bloomsphere.js +22 -69
  227. package/lib/heatmap/index.js +22 -35
  228. package/lib/heatmap/models/grid.js +27 -70
  229. package/lib/heatmap/models/grid3d.js +28 -71
  230. package/lib/heatmap/models/heatmap.js +14 -40
  231. package/lib/heatmap/models/hexagon.js +28 -71
  232. package/lib/image/index.js +17 -29
  233. package/lib/image/models/dataImage.js +54 -95
  234. package/lib/image/models/image.js +67 -110
  235. package/lib/image/models/tileDataImage.js +43 -86
  236. package/lib/index.js +5 -5
  237. package/lib/line/index.js +26 -53
  238. package/lib/line/models/arc.js +38 -75
  239. package/lib/line/models/arc_3d.js +34 -71
  240. package/lib/line/models/earthArc_3d.js +37 -74
  241. package/lib/line/models/great_circle.js +29 -72
  242. package/lib/line/models/half.js +17 -40
  243. package/lib/line/models/index.js +3 -0
  244. package/lib/line/models/line.js +47 -81
  245. package/lib/line/models/linearline.js +31 -72
  246. package/lib/line/models/simpleLine.js +34 -73
  247. package/lib/line/models/simpleTileLine.js +30 -72
  248. package/lib/line/models/tile.js +17 -40
  249. package/lib/line/models/wall.js +22 -69
  250. package/lib/mask/index.js +99 -28
  251. package/lib/mask/models/fill.js +16 -40
  252. package/lib/mask/models/index.js +4 -1
  253. package/lib/plugins/DataMappingPlugin.js +149 -91
  254. package/lib/plugins/DataSourcePlugin.js +30 -76
  255. package/lib/plugins/FeatureScalePlugin.js +61 -87
  256. package/lib/plugins/LayerModelPlugin.js +41 -128
  257. package/lib/plugins/LayerStylePlugin.js +6 -1
  258. package/lib/plugins/MultiPassRendererPlugin.js +1 -1
  259. package/lib/plugins/PixelPickingPlugin.js +1 -1
  260. package/lib/plugins/RegisterStyleAttributePlugin.js +16 -1
  261. package/lib/plugins/UpdateModelPlugin.js +0 -3
  262. package/lib/plugins/UpdateStyleAttributePlugin.js +6 -3
  263. package/lib/point/index.js +24 -56
  264. package/lib/point/models/earthExtrude.js +30 -75
  265. package/lib/point/models/earthFill.js +21 -68
  266. package/lib/point/models/extrude.js +17 -40
  267. package/lib/point/models/fill.js +21 -44
  268. package/lib/point/models/fillmage.js +43 -84
  269. package/lib/point/models/image.js +31 -74
  270. package/lib/point/models/index.js +3 -0
  271. package/lib/point/models/normal.js +30 -73
  272. package/lib/point/models/radar.js +35 -77
  273. package/lib/point/models/simplePoint.js +29 -72
  274. package/lib/point/models/text.js +109 -183
  275. package/lib/point/models/tile.js +35 -79
  276. package/lib/point/models/tileText.js +115 -151
  277. package/lib/polygon/index.js +25 -29
  278. package/lib/polygon/models/extrude.js +32 -71
  279. package/lib/polygon/models/fill.js +43 -78
  280. package/lib/polygon/models/index.js +3 -0
  281. package/lib/polygon/models/ocean.js +28 -71
  282. package/lib/polygon/models/tile.js +30 -72
  283. package/lib/polygon/models/water.js +28 -71
  284. package/lib/polygon/shaders/extrude/polygon_extrude_frag.glsl +2 -1
  285. package/lib/polygon/shaders/extrude/polygon_extrude_picklight_frag.glsl +2 -1
  286. package/lib/polygon/shaders/extrude/polygon_extrudetex_frag.glsl +2 -1
  287. package/lib/raster/index.js +22 -30
  288. package/lib/raster/models/index.js +4 -1
  289. package/lib/raster/models/raster.js +13 -36
  290. package/lib/raster/models/rasterRgb.js +13 -36
  291. package/lib/raster/models/rasterTile.js +36 -79
  292. package/lib/raster/raster.js +22 -44
  293. package/lib/tile/interaction/TilePickService.js +143 -0
  294. package/lib/tile/interaction/utils.js +11 -3
  295. package/lib/tile/manager/base.js +47 -213
  296. package/lib/tile/manager/layerManager.js +275 -0
  297. package/lib/tile/manager/mapLayerManager.js +134 -0
  298. package/lib/tile/models/tileModel.js +94 -0
  299. package/lib/tile/render/TileRenderService.js +78 -0
  300. package/lib/tile/style/TileStyleService.js +133 -0
  301. package/lib/tile/style/constants.js +19 -8
  302. package/lib/tile/style/utils.js +140 -0
  303. package/lib/tile/tileFactory/base.js +427 -0
  304. package/lib/tile/tileFactory/index.js +24 -42
  305. package/lib/tile/tileFactory/layers/{RasterDataLayer.js → rasterDataLayer.js} +21 -35
  306. package/lib/tile/tileFactory/layers/{TileDebugLayer.js → tileTest.js} +11 -24
  307. package/lib/tile/tileFactory/layers/vectorLayer.js +268 -0
  308. package/lib/tile/tileFactory/line.js +70 -0
  309. package/lib/tile/tileFactory/mask.js +71 -0
  310. package/lib/tile/tileFactory/point.js +71 -0
  311. package/lib/tile/tileFactory/polygon.js +70 -0
  312. package/lib/tile/tileFactory/raster.js +68 -0
  313. package/lib/tile/tileFactory/rasterData.js +93 -0
  314. package/lib/tile/tileFactory/test.js +106 -0
  315. package/lib/tile/tileLayer/MapTileLayer.js +63 -0
  316. package/lib/tile/tileLayer/TileLayer.js +215 -0
  317. package/lib/tile/tileLayer/base.js +225 -0
  318. package/lib/tile/utils.js +148 -0
  319. package/lib/utils/dataMappingStyle.js +20 -18
  320. package/lib/utils/layerData.js +10 -4
  321. package/lib/wind/index.js +17 -29
  322. package/lib/wind/models/wind.js +104 -125
  323. package/package.json +7 -7
  324. package/es/core/LayerPickService.d.ts +0 -9
  325. package/es/core/LayerPickService.js +0 -85
  326. package/es/tile/service/TileLayerService.d.ts +0 -33
  327. package/es/tile/service/TileLayerService.js +0 -172
  328. package/es/tile/service/TilePickService.d.ts +0 -22
  329. package/es/tile/service/TilePickService.js +0 -148
  330. package/es/tile/service/TileSourceService.d.ts +0 -7
  331. package/es/tile/service/TileSourceService.js +0 -39
  332. package/es/tile/tileFactory/DebugTile.d.ts +0 -16
  333. package/es/tile/tileFactory/DebugTile.js +0 -100
  334. package/es/tile/tileFactory/ImageTile.d.ts +0 -14
  335. package/es/tile/tileFactory/ImageTile.js +0 -89
  336. package/es/tile/tileFactory/MaskTile.d.ts +0 -17
  337. package/es/tile/tileFactory/MaskTile.js +0 -98
  338. package/es/tile/tileFactory/RasterRGBTile.d.ts +0 -16
  339. package/es/tile/tileFactory/RasterRGBTile.js +0 -91
  340. package/es/tile/tileFactory/RasterTile.d.ts +0 -27
  341. package/es/tile/tileFactory/RasterTile.js +0 -186
  342. package/es/tile/tileFactory/Tile.d.ts +0 -34
  343. package/es/tile/tileFactory/Tile.js +0 -199
  344. package/es/tile/tileFactory/VectorTile.d.ts +0 -20
  345. package/es/tile/tileFactory/VectorTile.js +0 -152
  346. package/es/tile/tileFactory/util.d.ts +0 -6
  347. package/es/tile/tileFactory/util.js +0 -33
  348. package/es/tile/tileLayer/BaseLayer.d.ts +0 -46
  349. package/es/tile/tileLayer/BaseLayer.js +0 -358
  350. package/lib/core/LayerPickService.js +0 -96
  351. package/lib/tile/service/TileLayerService.js +0 -185
  352. package/lib/tile/service/TilePickService.js +0 -162
  353. package/lib/tile/service/TileSourceService.js +0 -59
  354. package/lib/tile/tileFactory/DebugTile.js +0 -115
  355. package/lib/tile/tileFactory/ImageTile.js +0 -104
  356. package/lib/tile/tileFactory/MaskTile.js +0 -113
  357. package/lib/tile/tileFactory/RasterRGBTile.js +0 -106
  358. package/lib/tile/tileFactory/RasterTile.js +0 -205
  359. package/lib/tile/tileFactory/Tile.js +0 -210
  360. package/lib/tile/tileFactory/VectorTile.js +0 -167
  361. package/lib/tile/tileFactory/util.js +0 -48
  362. package/lib/tile/tileLayer/BaseLayer.js +0 -373
@@ -5,8 +5,8 @@ export default class MaskModel extends BaseModel {
5
5
  u_opacity: number;
6
6
  u_color: number[];
7
7
  };
8
- initModels(): Promise<IModel[]>;
9
- buildModels(): Promise<IModel[]>;
8
+ initModels(callbackModel: (models: IModel[]) => void): void;
9
+ buildModels(callbackModel: (models: IModel[]) => void): Promise<void>;
10
10
  clearModels(refresh?: boolean): void;
11
11
  protected registerBuiltinAttributes(): string;
12
12
  }
@@ -49,43 +49,18 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
49
49
  }
50
50
  }, {
51
51
  key: "initModels",
52
- value: function () {
53
- var _initModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
54
- return _regeneratorRuntime.wrap(function _callee$(_context) {
55
- while (1) {
56
- switch (_context.prev = _context.next) {
57
- case 0:
58
- _context.next = 2;
59
- return this.buildModels();
60
-
61
- case 2:
62
- return _context.abrupt("return", _context.sent);
63
-
64
- case 3:
65
- case "end":
66
- return _context.stop();
67
- }
68
- }
69
- }, _callee, this);
70
- }));
71
-
72
- function initModels() {
73
- return _initModels.apply(this, arguments);
74
- }
75
-
76
- return initModels;
77
- }()
52
+ value: function initModels(callbackModel) {
53
+ this.buildModels(callbackModel);
54
+ }
78
55
  }, {
79
56
  key: "buildModels",
80
57
  value: function () {
81
- var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
82
- var model;
83
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
58
+ var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(callbackModel) {
59
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
84
60
  while (1) {
85
- switch (_context2.prev = _context2.next) {
61
+ switch (_context.prev = _context.next) {
86
62
  case 0:
87
- _context2.next = 2;
88
- return this.layer.buildLayerModel({
63
+ this.layer.buildLayerModel({
89
64
  moduleName: 'mask',
90
65
  vertexShader: mask_vert,
91
66
  fragmentShader: mask_frag,
@@ -109,21 +84,22 @@ var MaskModel = /*#__PURE__*/function (_BaseModel) {
109
84
  }
110
85
  },
111
86
  pick: false
87
+ }).then(function (model) {
88
+ callbackModel([model]);
89
+ }).catch(function (err) {
90
+ console.warn(err);
91
+ callbackModel([]);
112
92
  });
113
93
 
114
- case 2:
115
- model = _context2.sent;
116
- return _context2.abrupt("return", [model]);
117
-
118
- case 4:
94
+ case 1:
119
95
  case "end":
120
- return _context2.stop();
96
+ return _context.stop();
121
97
  }
122
98
  }
123
- }, _callee2, this);
99
+ }, _callee, this);
124
100
  }));
125
101
 
126
- function buildModels() {
102
+ function buildModels(_x) {
127
103
  return _buildModels.apply(this, arguments);
128
104
  }
129
105
 
@@ -1,4 +1,4 @@
1
- export declare type MaskModelType = 'fill';
1
+ export declare type MaskModelType = 'fill' | 'vectorMask';
2
2
  declare const MaskModels: {
3
3
  [key in MaskModelType]: any;
4
4
  };
@@ -1,5 +1,7 @@
1
+ import MaskTileModel from "../../tile/models/tileModel";
1
2
  import FillModel from "./fill";
2
3
  var MaskModels = {
3
- fill: FillModel
4
+ fill: FillModel,
5
+ vectorMask: MaskTileModel
4
6
  };
5
7
  export default MaskModels;
@@ -8,9 +8,11 @@ export default class DataMappingPlugin implements ILayerPlugin {
8
8
  }): void;
9
9
  private generateMaping;
10
10
  private mapping;
11
+ private mapLayerMapping;
11
12
  private adjustData2Amap2Coordinates;
12
13
  private adjustData2SimpleCoordinates;
13
14
  private unProjectCoordinates;
14
15
  private applyAttributeMapping;
16
+ private applyMapLayerAttributeMapping;
15
17
  private getArrowPoints;
16
18
  }
@@ -1,5 +1,4 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
2
  import _initializerDefineProperty from "@babel/runtime/helpers/esm/initializerDefineProperty";
4
3
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
5
4
  import _createClass from "@babel/runtime/helpers/esm/createClass";
@@ -9,10 +8,9 @@ import _initializerWarningHelper from "@babel/runtime/helpers/esm/initializerWar
9
8
 
10
9
  var _dec, _dec2, _dec3, _class, _class2, _descriptor, _descriptor2;
11
10
 
12
- import _regeneratorRuntime from "@babel/runtime/regenerator";
13
11
  import { TYPES } from '@antv/l7-core';
14
12
  import { Version } from '@antv/l7-maps';
15
- import { normalize, rgb2arr } from '@antv/l7-utils';
13
+ import { isColor, normalize, rgb2arr } from '@antv/l7-utils';
16
14
  import { inject, injectable } from 'inversify';
17
15
  import { cloneDeep } from 'lodash';
18
16
  import 'reflect-metadata';
@@ -31,73 +29,59 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
31
29
  var _this = this;
32
30
 
33
31
  var styleAttributeService = _ref.styleAttributeService;
34
- layer.hooks.init.tapPromise('DataMappingPlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
35
- return _regeneratorRuntime.wrap(function _callee$(_context) {
36
- while (1) {
37
- switch (_context.prev = _context.next) {
38
- case 0:
39
- // 初始化重新生成 map
40
- _this.generateMaping(layer, {
41
- styleAttributeService: styleAttributeService
42
- });
43
-
44
- case 1:
45
- case "end":
46
- return _context.stop();
47
- }
48
- }
49
- }, _callee);
50
- })));
51
- layer.hooks.beforeRenderData.tapPromise('DataMappingPlugin', /*#__PURE__*/function () {
52
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(flag) {
53
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
54
- while (1) {
55
- switch (_context2.prev = _context2.next) {
56
- case 0:
57
- if (flag) {
58
- _context2.next = 2;
59
- break;
60
- }
61
-
62
- return _context2.abrupt("return", flag);
63
-
64
- case 2:
65
- layer.dataState.dataMappingNeedUpdate = false;
66
-
67
- _this.generateMaping(layer, {
68
- styleAttributeService: styleAttributeService
69
- });
70
-
71
- return _context2.abrupt("return", true);
72
-
73
- case 5:
74
- case "end":
75
- return _context2.stop();
76
- }
77
- }
78
- }, _callee2);
79
- }));
32
+ layer.hooks.init.tap('DataMappingPlugin', function () {
33
+ // 初始化重新生成 map
34
+ var source = layer.getSource();
80
35
 
81
- return function (_x) {
82
- return _ref3.apply(this, arguments);
83
- };
84
- }()); // remapping before render
36
+ if (source.inited) {
37
+ _this.generateMaping(layer, {
38
+ styleAttributeService: styleAttributeService
39
+ });
40
+ } else {
41
+ source.once('update', function () {
42
+ _this.generateMaping(layer, {
43
+ styleAttributeService: styleAttributeService
44
+ });
45
+ });
46
+ }
47
+ });
48
+ layer.hooks.beforeRenderData.tap('DataMappingPlugin', function () {
49
+ layer.dataState.dataMappingNeedUpdate = false;
50
+ var source = layer.getSource();
51
+
52
+ if (source.inited) {
53
+ _this.generateMaping(layer, {
54
+ styleAttributeService: styleAttributeService
55
+ });
56
+ } else {
57
+ source.once('update', function () {
58
+ _this.generateMaping(layer, {
59
+ styleAttributeService: styleAttributeService
60
+ });
61
+ });
62
+ }
63
+
64
+ return true;
65
+ }); // remapping before render
85
66
 
86
67
  layer.hooks.beforeRender.tap('DataMappingPlugin', function () {
87
- var source = layer.getSource();
68
+ var _layer$getLayerConfig = layer.getLayerConfig(),
69
+ usage = _layer$getLayerConfig.usage;
88
70
 
89
- if (layer.layerModelNeedUpdate || !source || !source.inited) {
71
+ if (usage === 'basemap') {
90
72
  return;
91
73
  }
92
74
 
93
- var attributes = styleAttributeService.getLayerStyleAttributes() || [];
94
- var filter = styleAttributeService.getLayerStyleAttribute('filter');
95
- var dataArray = source.data.dataArray; // TODO 数据为空的情况
75
+ var source = layer.getSource();
96
76
 
97
- if (Array.isArray(dataArray) && dataArray.length === 0) {
77
+ if (layer.layerModelNeedUpdate || !source || !source.inited) {
98
78
  return;
99
79
  }
100
80
 
81
+ var bottomColor = layer.getBottomColor();
82
+ var attributes = styleAttributeService.getLayerStyleAttributes() || [];
83
+ var filter = styleAttributeService.getLayerStyleAttribute('filter');
84
+ var dataArray = source.data.dataArray;
101
85
  var attributesToRemapping = attributes.filter(function (attribute) {
102
86
  return attribute.needRemapping;
103
87
  } // 如果filter变化
@@ -106,33 +90,35 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
106
90
 
107
91
  if (filter !== null && filter !== void 0 && filter.needRemapping && filter !== null && filter !== void 0 && filter.scale) {
108
92
  filterData = dataArray.filter(function (record) {
109
- return _this.applyAttributeMapping(filter, record)[0];
93
+ return _this.applyAttributeMapping(filter, record, bottomColor)[0];
110
94
  });
111
95
  }
112
96
 
113
97
  if (attributesToRemapping.length) {
114
98
  // 过滤数据
115
99
  if (filter !== null && filter !== void 0 && filter.needRemapping) {
116
- var encodeData = _this.mapping(layer, attributes, filterData, undefined);
100
+ var encodeData = _this.mapping(layer, attributes, filterData, undefined, bottomColor);
117
101
 
118
102
  layer.setEncodedData(encodeData);
119
103
  filter.needRemapping = false;
120
104
  } else {
121
- var _encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData());
105
+ var _encodeData = _this.mapping(layer, attributesToRemapping, filterData, layer.getEncodedData(), bottomColor);
122
106
 
123
107
  layer.setEncodedData(_encodeData);
124
- } // 处理文本更新,更新文字形状
125
- // layer.emit('remapping', null);
108
+ } // 处理文本更新
109
+
126
110
 
111
+ layer.emit('remapping', null);
127
112
  }
128
113
  });
129
114
  }
130
115
  }, {
131
116
  key: "generateMaping",
132
- value: function generateMaping(layer, _ref4) {
117
+ value: function generateMaping(layer, _ref2) {
133
118
  var _this2 = this;
134
119
 
135
- var styleAttributeService = _ref4.styleAttributeService;
120
+ var styleAttributeService = _ref2.styleAttributeService;
121
+ var bottomColor = layer.getBottomColor();
136
122
  var attributes = styleAttributeService.getLayerStyleAttributes() || [];
137
123
  var filter = styleAttributeService.getLayerStyleAttribute('filter');
138
124
  var dataArray = layer.getSource().data.dataArray;
@@ -140,29 +126,30 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
140
126
 
141
127
  if (filter !== null && filter !== void 0 && filter.scale) {
142
128
  filterData = dataArray.filter(function (record) {
143
- return _this2.applyAttributeMapping(filter, record)[0];
129
+ return _this2.applyAttributeMapping(filter, record, bottomColor)[0];
144
130
  });
145
- } // Tip: layer 对数据做处理
146
- // 数据处理 在数据进行 mapping 生成 encodeData 之前对数据进行处理
147
- // 在各个 layer 中继承
148
-
131
+ }
149
132
 
150
- filterData = layer.processData(filterData);
151
- var encodeData = this.mapping(layer, attributes, filterData, undefined);
133
+ var encodeData = this.mapping(layer, attributes, filterData, undefined, bottomColor);
152
134
  layer.setEncodedData(encodeData); // 对外暴露事件
153
135
 
154
136
  layer.emit('dataUpdate', null);
155
137
  }
156
138
  }, {
157
139
  key: "mapping",
158
- value: function mapping(layer, attributes, data, predata) {
140
+ value: function mapping(layer, attributes, data, predata, minimumColor) {
159
141
  var _this3 = this;
160
142
 
161
- var _ref5 = layer.getLayerConfig(),
162
- _ref5$arrow = _ref5.arrow,
163
- arrow = _ref5$arrow === void 0 ? {
143
+ var _ref3 = layer.getLayerConfig(),
144
+ _ref3$arrow = _ref3.arrow,
145
+ arrow = _ref3$arrow === void 0 ? {
164
146
  enable: false
165
- } : _ref5$arrow;
147
+ } : _ref3$arrow,
148
+ usage = _ref3.usage;
149
+
150
+ if (usage === 'basemap') {
151
+ return this.mapLayerMapping(layer, attributes, data, predata);
152
+ }
166
153
 
167
154
  var usedAttributes = attributes.filter(function (attribute) {
168
155
  return attribute.scale !== undefined;
@@ -176,7 +163,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
176
163
  }, preRecord);
177
164
 
178
165
  usedAttributes.forEach(function (attribute) {
179
- var values = _this3.applyAttributeMapping(attribute, record);
166
+ var values = _this3.applyAttributeMapping(attribute, record, minimumColor);
180
167
 
181
168
  attribute.needRemapping = false; // TODO: 支持每个属性配置 postprocess
182
169
 
@@ -216,10 +203,57 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
216
203
  this.adjustData2SimpleCoordinates(mappedData);
217
204
  return mappedData;
218
205
  }
206
+ }, {
207
+ key: "mapLayerMapping",
208
+ value: function mapLayerMapping(layer, attributes, data, predata) {
209
+ var _this4 = this;
210
+
211
+ var usedAttributes = attributes.filter(function (attribute) {
212
+ return attribute.scale !== undefined;
213
+ });
214
+ var mappedData = data.map(function (record, i) {
215
+ var preRecord = predata ? predata[i] : {};
216
+
217
+ var encodeRecord = _objectSpread({
218
+ id: record._id,
219
+ coordinates: record.coordinates
220
+ }, preRecord);
221
+
222
+ usedAttributes.forEach(function (attribute) {
223
+ var _layer$shapeOption;
224
+
225
+ if (attribute.name === 'shape' && // @ts-ignore
226
+ ((_layer$shapeOption = layer.shapeOption) === null || _layer$shapeOption === void 0 ? void 0 : _layer$shapeOption.field) === 'simple') {
227
+ encodeRecord[attribute.name] = 'simple';
228
+ attribute.needRemapping = false;
229
+ } else {
230
+ var values = _this4.applyMapLayerAttributeMapping(attribute, record);
231
+
232
+ attribute.needRemapping = false; // @ts-ignore
233
+
234
+ encodeRecord[attribute.name] = Array.isArray(values) && values.length === 1 ? values[0] : values; // 增加对 layer/text/iconfont unicode 映射的解析
235
+
236
+ if (attribute.name === 'shape') {
237
+ encodeRecord.shape = _this4.fontService.getIconFontKey(encodeRecord[attribute.name]);
238
+ }
239
+ }
240
+ });
241
+
242
+ if (encodeRecord.size === undefined) {
243
+ // in case not set size
244
+ encodeRecord.size = 1;
245
+ }
246
+
247
+ return encodeRecord;
248
+ }); // 调整数据兼容 Amap2.0
249
+
250
+ this.adjustData2Amap2Coordinates(mappedData, layer);
251
+ return mappedData;
252
+ }
219
253
  }, {
220
254
  key: "adjustData2Amap2Coordinates",
221
255
  value: function adjustData2Amap2Coordinates(mappedData, layer) {
222
- var _this4 = this;
256
+ var _this5 = this;
223
257
 
224
258
  // 根据地图的类型判断是否需要对点位数据进行处理, 若是高德2.0则需要对坐标进行相对偏移
225
259
  if (mappedData.length > 0 && this.mapService.version === Version['GAODE2.x']) {
@@ -238,7 +272,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
238
272
  // @ts-ignore
239
273
  // d.coordinates = this.mapService.lngLatToCoord(d.coordinates);
240
274
 
241
- d.coordinates = _this4.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
275
+ d.coordinates = _this5.mapService.lngLatToCoordByLayer(d.coordinates, layerCenter);
242
276
  });
243
277
  } else {
244
278
  // 连续的线、面数据
@@ -252,7 +286,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
252
286
  // @ts-ignore
253
287
  // d.coordinates = this.mapService.lngLatToCoords(d.coordinates);
254
288
 
255
- d.coordinates = _this4.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
289
+ d.coordinates = _this5.mapService.lngLatToCoordsByLayer(d.coordinates, layerCenter);
256
290
  });
257
291
  }
258
292
  }
@@ -260,12 +294,12 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
260
294
  }, {
261
295
  key: "adjustData2SimpleCoordinates",
262
296
  value: function adjustData2SimpleCoordinates(mappedData) {
263
- var _this5 = this;
297
+ var _this6 = this;
264
298
 
265
299
  if (mappedData.length > 0 && this.mapService.version === Version.SIMPLE) {
266
300
  mappedData.map(function (d) {
267
301
  if (!d.simpleCoordinate) {
268
- d.coordinates = _this5.unProjectCoordinates(d.coordinates);
302
+ d.coordinates = _this6.unProjectCoordinates(d.coordinates);
269
303
  d.simpleCoordinate = true;
270
304
  }
271
305
  });
@@ -274,7 +308,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
274
308
  }, {
275
309
  key: "unProjectCoordinates",
276
310
  value: function unProjectCoordinates(coordinates) {
277
- var _this6 = this;
311
+ var _this7 = this;
278
312
 
279
313
  if (typeof coordinates[0] === 'number') {
280
314
  return this.mapService.simpleMapCoord.unproject(coordinates);
@@ -287,7 +321,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
287
321
  // @ts-ignore
288
322
  var c1 = [];
289
323
  coord.map(function (co) {
290
- c1.push(_this6.mapService.simpleMapCoord.unproject(co));
324
+ c1.push(_this7.mapService.simpleMapCoord.unproject(co));
291
325
  }); // @ts-ignore
292
326
 
293
327
  coords.push(c1);
@@ -299,7 +333,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
299
333
  var _coords = []; // @ts-ignore
300
334
 
301
335
  coordinates.map(function (coord) {
302
- _coords.push(_this6.mapService.simpleMapCoord.unproject(coord));
336
+ _coords.push(_this7.mapService.simpleMapCoord.unproject(coord));
303
337
  }); // @ts-ignore
304
338
 
305
339
  return _coords;
@@ -307,7 +341,7 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
307
341
  }
308
342
  }, {
309
343
  key: "applyAttributeMapping",
310
- value: function applyAttributeMapping(attribute, record) {
344
+ value: function applyAttributeMapping(attribute, record, minimumColor) {
311
345
  var _attribute$scale;
312
346
 
313
347
  if (!attribute.scale) {
@@ -316,10 +350,10 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
316
350
 
317
351
  var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale = attribute.scale) === null || _attribute$scale === void 0 ? void 0 : _attribute$scale.scalers) || [];
318
352
  var params = [];
319
- scalers.forEach(function (_ref6) {
353
+ scalers.forEach(function (_ref4) {
320
354
  var _attribute$scale2;
321
355
 
322
- var field = _ref6.field;
356
+ var field = _ref4.field;
323
357
 
324
358
  if (record.hasOwnProperty(field) || ((_attribute$scale2 = attribute.scale) === null || _attribute$scale2 === void 0 ? void 0 : _attribute$scale2.type) === 'variable') {
325
359
  // TODO:多字段,常量
@@ -327,8 +361,36 @@ var DataMappingPlugin = (_dec = injectable(), _dec2 = inject(TYPES.IMapService),
327
361
  }
328
362
  });
329
363
  var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
364
+
365
+ if (attribute.name === 'color' && !isColor(mappingResult[0])) {
366
+ return [minimumColor];
367
+ }
368
+
330
369
  return mappingResult; // return attribute.mapping ? attribute.mapping(params) : [];
331
370
  }
371
+ }, {
372
+ key: "applyMapLayerAttributeMapping",
373
+ value: function applyMapLayerAttributeMapping(attribute, record) {
374
+ var _attribute$scale3;
375
+
376
+ if (!attribute.scale) {
377
+ return [];
378
+ }
379
+
380
+ var scalers = (attribute === null || attribute === void 0 ? void 0 : (_attribute$scale3 = attribute.scale) === null || _attribute$scale3 === void 0 ? void 0 : _attribute$scale3.scalers) || [];
381
+ var params = [];
382
+ scalers.forEach(function (_ref5) {
383
+ var _attribute$scale4;
384
+
385
+ var field = _ref5.field;
386
+
387
+ if (record.hasOwnProperty(field) || ((_attribute$scale4 = attribute.scale) === null || _attribute$scale4 === void 0 ? void 0 : _attribute$scale4.type) === 'variable') {
388
+ params.push(record[field]);
389
+ }
390
+ });
391
+ var mappingResult = attribute.mapping ? attribute.mapping(params) : [];
392
+ return mappingResult;
393
+ }
332
394
  }, {
333
395
  key: "getArrowPoints",
334
396
  value: function getArrowPoints(p1, p2) {
@@ -1,10 +1,8 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
2
1
  import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
3
2
  import _createClass from "@babel/runtime/helpers/esm/createClass";
4
3
 
5
4
  var _dec, _class;
6
5
 
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
6
  import { TYPES } from '@antv/l7-core';
9
7
  import Source from '@antv/l7-source';
10
8
  import { injectable } from 'inversify';
@@ -20,83 +18,41 @@ var DataSourcePlugin = (_dec = injectable(), _dec(_class = /*#__PURE__*/function
20
18
  var _this = this;
21
19
 
22
20
  this.mapService = layer.getContainer().get(TYPES.IMapService);
23
- layer.hooks.init.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
24
- var source, _ref2, data, options;
25
-
26
- return _regeneratorRuntime.wrap(function _callee$(_context) {
27
- while (1) {
28
- switch (_context.prev = _context.next) {
29
- case 0:
30
- source = layer.getSource();
31
-
32
- if (!source) {
33
- // Tip: 用户没有传入 source 的时候使用图层的默认数据
34
- _ref2 = layer.sourceOption || layer.defaultSourceConfig, data = _ref2.data, options = _ref2.options;
35
- source = new Source(data, options);
36
- layer.setSource(source); // await new Promise((resolve) => {
37
- // source.on('update', (e) => {
38
- // if (e.type === 'inited') {
39
- // layer.initSource(source);
40
- // }
41
- // resolve(null);
42
- // });
43
- // });
44
- }
45
-
46
- if (!source.inited) {
47
- _context.next = 6;
48
- break;
49
- }
50
-
51
- _this.updateClusterData(layer);
52
-
53
- _context.next = 8;
54
- break;
55
-
56
- case 6:
57
- _context.next = 8;
58
- return new Promise(function (resolve) {
59
- source.on('update', function (e) {
60
- if (e.type === 'inited') {
61
- _this.updateClusterData(layer);
62
- }
63
-
64
- resolve(null);
65
- });
66
- });
67
-
68
- case 8:
69
- case "end":
70
- return _context.stop();
71
- }
72
- }
73
- }, _callee);
74
- }))); // 检测数据是否需要更新
75
-
76
- layer.hooks.beforeRenderData.tapPromise('DataSourcePlugin', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
77
- var neeUpdateCluster, dataSourceNeedUpdate;
78
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
79
- while (1) {
80
- switch (_context2.prev = _context2.next) {
81
- case 0:
82
- neeUpdateCluster = _this.updateClusterData(layer);
83
- dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
84
- layer.dataState.dataSourceNeedUpdate = false;
85
- return _context2.abrupt("return", neeUpdateCluster || dataSourceNeedUpdate);
86
-
87
- case 4:
88
- case "end":
89
- return _context2.stop();
90
- }
91
- }
92
- }, _callee2);
93
- })));
21
+ layer.hooks.init.tap('DataSourcePlugin', function () {
22
+ var source = layer.getSource();
23
+
24
+ if (!source) {
25
+ // Tip: 用户没有传入 source 的时候使用图层的默认数据
26
+ var _ref = layer.sourceOption || layer.defaultSourceConfig,
27
+ data = _ref.data,
28
+ options = _ref.options;
29
+
30
+ source = new Source(data, options);
31
+ layer.setSource(source);
32
+ }
33
+
34
+ if (source.inited) {
35
+ _this.updateClusterData(layer);
36
+ } else {
37
+ source.once('update', function () {
38
+ _this.updateClusterData(layer);
39
+ });
40
+ }
41
+ }); // 检测数据是否需要更新
42
+
43
+ layer.hooks.beforeRenderData.tap('DataSourcePlugin', function () {
44
+ var neeUpdateCluster = _this.updateClusterData(layer);
45
+
46
+ var dataSourceNeedUpdate = layer.dataState.dataSourceNeedUpdate;
47
+ layer.dataState.dataSourceNeedUpdate = false;
48
+ return neeUpdateCluster || dataSourceNeedUpdate;
49
+ });
94
50
  }
95
51
  }, {
96
52
  key: "updateClusterData",
97
53
  value: function updateClusterData(layer) {
98
54
  // Tip: 矢量瓦片不需要进行聚合操作
99
- if (layer.isTileLayer || layer.tileLayer || !layer.getSource()) {
55
+ if (layer.isTileLayer || layer.tileLayer) {
100
56
  return false;
101
57
  }
102
58
 
@@ -5,6 +5,7 @@ import 'reflect-metadata';
5
5
  */
6
6
  export default class FeatureScalePlugin implements ILayerPlugin {
7
7
  private scaleOptions;
8
+ private getSourceData;
8
9
  apply(layer: ILayer, { styleAttributeService, }: {
9
10
  styleAttributeService: IStyleAttributeService;
10
11
  }): void;