@antv/l7-layers 2.17.4 → 2.17.6

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 (250) 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 +325 -483
  10. package/es/core/BaseModel.js +51 -80
  11. package/es/core/CommonStyleAttribute.js +2 -5
  12. package/es/core/LayerPickService.js +21 -32
  13. package/es/core/TextureService.js +0 -13
  14. package/es/core/interface.js +17 -24
  15. package/es/core/shape/Path.js +13 -20
  16. package/es/core/shape/extrude.js +27 -39
  17. package/es/core/triangulation.js +99 -136
  18. package/es/earth/index.js +9 -33
  19. package/es/earth/models/atmosphere.js +30 -54
  20. package/es/earth/models/base.js +47 -85
  21. package/es/earth/models/bloomsphere.js +30 -54
  22. package/es/earth/utils.js +9 -13
  23. package/es/heatmap/index.js +10 -40
  24. package/es/heatmap/models/grid.js +28 -52
  25. package/es/heatmap/models/grid3d.js +28 -52
  26. package/es/heatmap/models/heatmap.js +92 -149
  27. package/es/heatmap/models/hexagon.js +28 -52
  28. package/es/heatmap/triangulation.js +0 -4
  29. package/es/image/index.js +9 -28
  30. package/es/image/models/image.js +66 -100
  31. package/es/index.js +9 -17
  32. package/es/line/index.js +9 -35
  33. package/es/line/models/arc.js +63 -112
  34. package/es/line/models/arc_3d.js +58 -102
  35. package/es/line/models/earthArc_3d.js +60 -105
  36. package/es/line/models/flow.js +36 -60
  37. package/es/line/models/great_circle.js +53 -94
  38. package/es/line/models/line.js +92 -144
  39. package/es/line/models/linearline.js +42 -74
  40. package/es/line/models/simpleLine.js +38 -67
  41. package/es/line/models/wall.js +52 -92
  42. package/es/line/shaders/dash/line_dash_vert.glsl +1 -2
  43. package/es/line/shaders/line_frag.glsl +1 -3
  44. package/es/line/shaders/line_vert.glsl +2 -0
  45. package/es/line/shaders/linear/line_linear_frag.glsl +1 -1
  46. package/es/mask/index.js +9 -28
  47. package/es/mask/models/fill.js +29 -54
  48. package/es/plugins/DataMappingPlugin.js +78 -114
  49. package/es/plugins/DataSourcePlugin.js +45 -68
  50. package/es/plugins/FeatureScalePlugin.js +67 -122
  51. package/es/plugins/LayerAnimateStylePlugin.js +0 -5
  52. package/es/plugins/LayerMaskPlugin.js +3 -11
  53. package/es/plugins/LayerModelPlugin.js +69 -118
  54. package/es/plugins/LayerStylePlugin.js +4 -9
  55. package/es/plugins/LightingPlugin.js +12 -18
  56. package/es/plugins/MultiPassRendererPlugin.js +11 -16
  57. package/es/plugins/PixelPickingPlugin.js +12 -21
  58. package/es/plugins/RegisterStyleAttributePlugin.js +5 -12
  59. package/es/plugins/ShaderUniformPlugin.js +13 -27
  60. package/es/plugins/UpdateModelPlugin.js +0 -5
  61. package/es/plugins/UpdateStyleAttributePlugin.js +5 -11
  62. package/es/point/index.js +26 -78
  63. package/es/point/models/earthExtrude.js +58 -95
  64. package/es/point/models/earthFill.js +52 -80
  65. package/es/point/models/extrude.js +57 -94
  66. package/es/point/models/fill.js +56 -81
  67. package/es/point/models/fillmage.js +60 -100
  68. package/es/point/models/image.js +47 -83
  69. package/es/point/models/index.js +2 -2
  70. package/es/point/models/normal.js +30 -54
  71. package/es/point/models/radar.js +38 -63
  72. package/es/point/models/simplePoint.js +38 -62
  73. package/es/point/models/text.js +199 -296
  74. package/es/point/shape/extrude.js +4 -13
  75. package/es/polygon/index.js +11 -41
  76. package/es/polygon/models/extrude.js +87 -135
  77. package/es/polygon/models/fill.js +50 -79
  78. package/es/polygon/models/index.js +3 -2
  79. package/es/polygon/models/ocean.js +42 -76
  80. package/es/polygon/models/water.js +37 -71
  81. package/es/raster/buffers/triangulation.js +2 -4
  82. package/es/raster/index.js +9 -32
  83. package/es/raster/models/raster.js +80 -116
  84. package/es/raster/models/rasterRgb.js +84 -127
  85. package/es/raster/models/rasterTerrainRgb.js +56 -84
  86. package/es/tile/interaction/getRasterData.js +14 -20
  87. package/es/tile/interaction/utils.js +7 -9
  88. package/es/tile/manager/base.js +63 -96
  89. package/es/tile/service/TileLayerService.js +33 -55
  90. package/es/tile/service/TilePickService.js +26 -40
  91. package/es/tile/service/TileSourceService.js +3 -7
  92. package/es/tile/tileFactory/DebugTile.js +29 -46
  93. package/es/tile/tileFactory/ImageTile.js +20 -38
  94. package/es/tile/tileFactory/MaskTile.js +22 -43
  95. package/es/tile/tileFactory/RasterRGBTile.js +22 -42
  96. package/es/tile/tileFactory/RasterTerrainRGBTile.js +20 -38
  97. package/es/tile/tileFactory/RasterTile.js +30 -53
  98. package/es/tile/tileFactory/Tile.js +63 -97
  99. package/es/tile/tileFactory/VectorTile.js +41 -68
  100. package/es/tile/tileFactory/index.js +0 -11
  101. package/es/tile/tileFactory/layers/TileDebugLayer.js +6 -27
  102. package/es/tile/tileFactory/util.js +0 -3
  103. package/es/tile/tileLayer/BaseLayer.js +105 -146
  104. package/es/tile/utils.js +1 -1
  105. package/es/utils/blend.js +0 -2
  106. package/es/utils/collision-index.js +9 -16
  107. package/es/utils/extrude_polyline.js +101 -149
  108. package/es/utils/grid-index.js +2 -27
  109. package/es/utils/identityScale.js +0 -8
  110. package/es/utils/layerData.js +30 -44
  111. package/es/utils/multiPassRender.js +11 -13
  112. package/es/utils/polylineNormal.js +31 -37
  113. package/es/utils/simpleLine.js +2 -16
  114. package/es/utils/stencil.js +2 -3
  115. package/es/utils/symbol-layout.js +27 -53
  116. package/es/wind/index.js +9 -29
  117. package/es/wind/models/utils.js +26 -51
  118. package/es/wind/models/wind.js +101 -147
  119. package/es/wind/models/windRender.js +53 -66
  120. package/lib/Geometry/index.js +9 -38
  121. package/lib/Geometry/models/billboard.js +51 -97
  122. package/lib/Geometry/models/index.js +0 -5
  123. package/lib/Geometry/models/plane.js +79 -151
  124. package/lib/Geometry/models/sprite.js +60 -127
  125. package/lib/canvas/index.js +10 -40
  126. package/lib/canvas/models/canvas.js +41 -101
  127. package/lib/canvas/models/index.js +0 -3
  128. package/lib/citybuliding/building.js +8 -35
  129. package/lib/citybuliding/models/build.js +57 -92
  130. package/lib/core/BaseLayer.js +325 -474
  131. package/lib/core/BaseModel.js +51 -90
  132. package/lib/core/CommonStyleAttribute.js +2 -7
  133. package/lib/core/LayerPickService.js +21 -37
  134. package/lib/core/TextureService.js +0 -16
  135. package/lib/core/interface.js +21 -31
  136. package/lib/core/schema.js +0 -1
  137. package/lib/core/shape/Path.js +14 -31
  138. package/lib/core/shape/extrude.js +27 -62
  139. package/lib/core/triangulation.js +98 -177
  140. package/lib/earth/index.js +9 -43
  141. package/lib/earth/models/atmosphere.js +30 -63
  142. package/lib/earth/models/base.js +47 -90
  143. package/lib/earth/models/bloomsphere.js +30 -63
  144. package/lib/earth/utils.js +7 -31
  145. package/lib/heatmap/index.js +10 -48
  146. package/lib/heatmap/models/grid.js +28 -60
  147. package/lib/heatmap/models/grid3d.js +28 -60
  148. package/lib/heatmap/models/heatmap.js +92 -166
  149. package/lib/heatmap/models/hexagon.js +28 -60
  150. package/lib/heatmap/models/index.js +0 -6
  151. package/lib/heatmap/triangulation.js +0 -5
  152. package/lib/image/index.js +9 -36
  153. package/lib/image/models/image.js +66 -109
  154. package/lib/image/models/index.js +0 -3
  155. package/lib/index.js +7 -61
  156. package/lib/line/index.js +9 -40
  157. package/lib/line/models/arc.js +61 -122
  158. package/lib/line/models/arc_3d.js +56 -113
  159. package/lib/line/models/earthArc_3d.js +58 -115
  160. package/lib/line/models/flow.js +36 -70
  161. package/lib/line/models/great_circle.js +53 -104
  162. package/lib/line/models/index.js +0 -11
  163. package/lib/line/models/line.js +90 -152
  164. package/lib/line/models/linearline.js +42 -86
  165. package/lib/line/models/simpleLine.js +38 -77
  166. package/lib/line/models/wall.js +52 -103
  167. package/lib/line/shaders/dash/line_dash_vert.glsl +1 -2
  168. package/lib/line/shaders/line_frag.glsl +1 -3
  169. package/lib/line/shaders/line_vert.glsl +2 -0
  170. package/lib/line/shaders/linear/line_linear_frag.glsl +1 -1
  171. package/lib/mask/index.js +9 -36
  172. package/lib/mask/models/fill.js +29 -63
  173. package/lib/mask/models/index.js +0 -3
  174. package/lib/plugins/DataMappingPlugin.js +78 -125
  175. package/lib/plugins/DataSourcePlugin.js +45 -76
  176. package/lib/plugins/FeatureScalePlugin.js +67 -138
  177. package/lib/plugins/LayerAnimateStylePlugin.js +0 -10
  178. package/lib/plugins/LayerMaskPlugin.js +4 -17
  179. package/lib/plugins/LayerModelPlugin.js +70 -127
  180. package/lib/plugins/LayerStylePlugin.js +5 -14
  181. package/lib/plugins/LightingPlugin.js +12 -25
  182. package/lib/plugins/MultiPassRendererPlugin.js +11 -22
  183. package/lib/plugins/PixelPickingPlugin.js +12 -27
  184. package/lib/plugins/RegisterStyleAttributePlugin.js +5 -19
  185. package/lib/plugins/ShaderUniformPlugin.js +13 -34
  186. package/lib/plugins/UpdateModelPlugin.js +1 -10
  187. package/lib/plugins/UpdateStyleAttributePlugin.js +5 -16
  188. package/lib/point/index.js +26 -83
  189. package/lib/point/models/earthExtrude.js +58 -106
  190. package/lib/point/models/earthFill.js +52 -110
  191. package/lib/point/models/extrude.js +57 -103
  192. package/lib/point/models/fill.js +54 -90
  193. package/lib/point/models/fillmage.js +58 -107
  194. package/lib/point/models/image.js +47 -92
  195. package/lib/point/models/index.js +1 -12
  196. package/lib/point/models/normal.js +30 -64
  197. package/lib/point/models/radar.js +38 -72
  198. package/lib/point/models/simplePoint.js +38 -72
  199. package/lib/point/models/text.js +199 -305
  200. package/lib/point/shape/extrude.js +4 -20
  201. package/lib/polygon/index.js +11 -48
  202. package/lib/polygon/models/extrude.js +87 -146
  203. package/lib/polygon/models/fill.js +50 -89
  204. package/lib/polygon/models/index.js +2 -14
  205. package/lib/polygon/models/ocean.js +42 -88
  206. package/lib/polygon/models/water.js +37 -82
  207. package/lib/raster/buffers/triangulation.js +3 -7
  208. package/lib/raster/index.js +9 -40
  209. package/lib/raster/models/index.js +0 -5
  210. package/lib/raster/models/raster.js +80 -125
  211. package/lib/raster/models/rasterRgb.js +84 -139
  212. package/lib/raster/models/rasterTerrainRgb.js +56 -93
  213. package/lib/tile/interaction/getRasterData.js +14 -25
  214. package/lib/tile/interaction/utils.js +7 -19
  215. package/lib/tile/manager/base.js +63 -104
  216. package/lib/tile/service/TileLayerService.js +33 -60
  217. package/lib/tile/service/TilePickService.js +26 -48
  218. package/lib/tile/service/TileSourceService.js +2 -16
  219. package/lib/tile/style/utils.js +0 -3
  220. package/lib/tile/tileFactory/DebugTile.js +29 -54
  221. package/lib/tile/tileFactory/ImageTile.js +20 -46
  222. package/lib/tile/tileFactory/MaskTile.js +22 -51
  223. package/lib/tile/tileFactory/RasterRGBTile.js +22 -50
  224. package/lib/tile/tileFactory/RasterTerrainRGBTile.js +20 -46
  225. package/lib/tile/tileFactory/RasterTile.js +30 -63
  226. package/lib/tile/tileFactory/Tile.js +63 -102
  227. package/lib/tile/tileFactory/VectorTile.js +41 -76
  228. package/lib/tile/tileFactory/index.js +0 -25
  229. package/lib/tile/tileFactory/layers/TileDebugLayer.js +6 -32
  230. package/lib/tile/tileFactory/util.js +0 -9
  231. package/lib/tile/tileLayer/BaseLayer.js +105 -153
  232. package/lib/tile/utils.js +1 -5
  233. package/lib/utils/blend.js +0 -5
  234. package/lib/utils/collision-index.js +9 -25
  235. package/lib/utils/extrude_polyline.js +101 -181
  236. package/lib/utils/grid-index.js +2 -28
  237. package/lib/utils/identityScale.js +0 -9
  238. package/lib/utils/layerData.js +30 -49
  239. package/lib/utils/multiPassRender.js +11 -16
  240. package/lib/utils/polylineNormal.js +31 -66
  241. package/lib/utils/simpleLine.js +2 -21
  242. package/lib/utils/stencil.js +0 -4
  243. package/lib/utils/symbol-layout.js +27 -55
  244. package/lib/wind/index.js +9 -37
  245. package/lib/wind/models/index.js +0 -3
  246. package/lib/wind/models/utils.js +26 -62
  247. package/lib/wind/models/wind.js +101 -157
  248. package/lib/wind/models/windRender.js +53 -71
  249. package/lib/wind/models/windShader.js +0 -1
  250. package/package.json +7 -7
@@ -7,33 +7,21 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConst
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
9
  import _regeneratorRuntime from "@babel/runtime/regenerator";
10
-
11
10
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
-
13
11
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
14
-
15
12
  import BaseLayer from "../../../core/BaseLayer";
16
-
17
13
  var TileDebugLayer = /*#__PURE__*/function (_BaseLayer) {
18
14
  _inherits(TileDebugLayer, _BaseLayer);
19
-
20
15
  var _super = _createSuper(TileDebugLayer);
21
-
22
16
  function TileDebugLayer() {
23
17
  var _this;
24
-
25
18
  _classCallCheck(this, TileDebugLayer);
26
-
27
19
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
20
  args[_key] = arguments[_key];
29
21
  }
30
-
31
22
  _this = _super.call.apply(_super, [this].concat(args));
32
-
33
23
  _defineProperty(_assertThisInitialized(_this), "type", 'TileDebugLayer');
34
-
35
24
  _defineProperty(_assertThisInitialized(_this), "zIndex", 10000);
36
-
37
25
  _defineProperty(_assertThisInitialized(_this), "defaultSourceConfig", {
38
26
  data: [],
39
27
  options: {
@@ -42,37 +30,28 @@ var TileDebugLayer = /*#__PURE__*/function (_BaseLayer) {
42
30
  }
43
31
  }
44
32
  });
45
-
46
33
  return _this;
47
34
  }
48
-
49
35
  _createClass(TileDebugLayer, [{
50
36
  key: "buildModels",
51
37
  value: function () {
52
38
  var _buildModels = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
53
39
  return _regeneratorRuntime.wrap(function _callee$(_context) {
54
- while (1) {
55
- switch (_context.prev = _context.next) {
56
- case 0:
57
- return _context.abrupt("return");
58
-
59
- case 1:
60
- case "end":
61
- return _context.stop();
62
- }
40
+ while (1) switch (_context.prev = _context.next) {
41
+ case 0:
42
+ return _context.abrupt("return");
43
+ case 1:
44
+ case "end":
45
+ return _context.stop();
63
46
  }
64
47
  }, _callee);
65
48
  }));
66
-
67
49
  function buildModels() {
68
50
  return _buildModels.apply(this, arguments);
69
51
  }
70
-
71
52
  return buildModels;
72
53
  }()
73
54
  }]);
74
-
75
55
  return TileDebugLayer;
76
56
  }(BaseLayer);
77
-
78
57
  export { TileDebugLayer as default };
@@ -5,15 +5,12 @@ export function getTileLayer(type) {
5
5
  if (type === 'PolygonLayer') {
6
6
  return PolygonLayer;
7
7
  }
8
-
9
8
  if (type === 'LineLayer') {
10
9
  return LineLayer;
11
10
  }
12
-
13
11
  if (type === 'PointLayer') {
14
12
  return PointLayer;
15
13
  }
16
-
17
14
  return PointLayer;
18
15
  }
19
16
  export function isNeedMask(type) {
@@ -9,96 +9,81 @@ import { TileLayerService } from "../service/TileLayerService";
9
9
  import { TilePickService } from "../service/TilePickService";
10
10
  import { ProxyFuncs } from "../style/constants";
11
11
  import { getTileFactory } from "../tileFactory";
12
-
13
12
  var BaseTileLayer = /*#__PURE__*/function () {
14
13
  // 瓦片数据管理器
14
+
15
15
  function BaseTileLayer(parent) {
16
16
  var _this = this;
17
-
18
17
  _classCallCheck(this, BaseTileLayer);
19
-
20
18
  _defineProperty(this, "initedTileset", false);
21
-
22
19
  _defineProperty(this, "mapchange", function () {
23
20
  var _this$tilesetManager;
24
-
25
21
  var _this$getCurrentView = _this.getCurrentView(),
26
- latLonBounds = _this$getCurrentView.latLonBounds,
27
- zoom = _this$getCurrentView.zoom;
28
-
22
+ latLonBounds = _this$getCurrentView.latLonBounds,
23
+ zoom = _this$getCurrentView.zoom;
29
24
  if (_this.mapService.version === 'GAODE1.x') {
30
25
  var _this$parent$getLayer = _this.parent.getLayerConfig(),
31
- visible = _this$parent$getLayer.visible;
32
-
26
+ visible = _this$parent$getLayer.visible;
33
27
  if (zoom < 2 && visible) {
34
28
  _this.parent.updateLayerConfig({
35
29
  visible: false
36
30
  });
37
-
38
31
  _this.layerService.reRender();
39
32
  } else if (zoom >= 2 && !visible) {
40
33
  _this.parent.updateLayerConfig({
41
34
  visible: true
42
35
  });
43
-
44
36
  _this.layerService.reRender();
45
37
  }
46
38
  }
47
-
48
39
  if (_this.lastViewStates && _this.lastViewStates.zoom === zoom && _this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
49
40
  return;
50
41
  }
51
-
52
42
  _this.lastViewStates = {
53
43
  zoom: zoom,
54
44
  latLonBounds: latLonBounds
55
45
  };
56
46
  (_this$tilesetManager = _this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.throttleUpdate(zoom, latLonBounds);
57
47
  });
58
-
59
48
  _defineProperty(this, "viewchange", debounce(this.mapchange, 24));
60
-
61
49
  this.parent = parent;
62
50
  var container = this.parent.getContainer();
63
51
  this.rendererService = container.get(TYPES.IRendererService);
64
52
  this.layerService = container.get(TYPES.ILayerService);
65
53
  this.mapService = container.get(TYPES.IMapService);
66
- this.pickingService = container.get(TYPES.IPickingService); // 初始化瓦片管理服务
54
+ this.pickingService = container.get(TYPES.IPickingService);
67
55
 
56
+ // 初始化瓦片管理服务
68
57
  this.tileLayerService = new TileLayerService({
69
58
  rendererService: this.rendererService,
70
59
  layerService: this.layerService,
71
60
  parent: parent
72
- }); // 初始化拾取服务
73
-
61
+ });
62
+ // 初始化拾取服务
74
63
  this.tilePickService = new TilePickService({
75
64
  tileLayerService: this.tileLayerService,
76
65
  layerService: this.layerService,
77
66
  parent: parent
78
- }); // 重置
67
+ });
79
68
 
69
+ // 重置
80
70
  this.parent.setLayerPickService(this.tilePickService);
81
71
  this.proxy(parent);
82
72
  this.initTileSetManager();
83
73
  }
84
-
85
74
  _createClass(BaseTileLayer, [{
86
75
  key: "initTileSetManager",
87
76
  value: function initTileSetManager() {
88
77
  var _this$tilesetManager2;
89
-
90
78
  var source = this.parent.getSource();
91
79
  this.tilesetManager = source.tileset;
92
-
93
80
  if (!this.initedTileset) {
94
81
  this.bindTilesetEvent();
95
82
  this.initedTileset = true;
96
83
  }
97
-
98
84
  var _this$getCurrentView2 = this.getCurrentView(),
99
- latLonBounds = _this$getCurrentView2.latLonBounds,
100
- zoom = _this$getCurrentView2.zoom;
101
-
85
+ latLonBounds = _this$getCurrentView2.latLonBounds,
86
+ zoom = _this$getCurrentView2.zoom;
102
87
  (_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds);
103
88
  }
104
89
  }, {
@@ -116,27 +101,31 @@ var BaseTileLayer = /*#__PURE__*/function () {
116
101
  key: "bindTilesetEvent",
117
102
  value: function bindTilesetEvent() {
118
103
  var _this2 = this;
119
-
120
104
  // 瓦片数据加载成功
121
105
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
122
- this.tilesetManager.on('tile-loaded', function (tile) {// 将事件抛出,图层上可以监听使用
123
- }); // 瓦片数据从缓存删除或被执行重新加载
106
+ this.tilesetManager.on('tile-loaded', function (tile) {
107
+ // 将事件抛出,图层上可以监听使用
108
+ });
124
109
 
110
+ // 瓦片数据从缓存删除或被执行重新加载
125
111
  this.tilesetManager.on('tile-unload', function (tile) {
126
112
  // 将事件抛出,图层上可以监听使用
127
113
  _this2.tileUnLoad(tile);
128
- }); // 瓦片数据加载失败
129
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
114
+ });
130
115
 
116
+ // 瓦片数据加载失败
117
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
131
118
  this.tilesetManager.on('tile-error', function (error, tile) {
132
119
  // 将事件抛出,图层上可以监听使用
133
120
  _this2.tileError(error);
134
- }); // 瓦片显隐状态更新
121
+ });
135
122
 
123
+ // 瓦片显隐状态更新
136
124
  this.tilesetManager.on('tile-update', function () {
137
125
  _this2.tileUpdate();
138
- }); // 地图视野发生改变
126
+ });
139
127
 
128
+ // 地图视野发生改变
140
129
  this.mapService.on('zoomend', this.mapchange);
141
130
  this.mapService.on('moveend', this.viewchange);
142
131
  }
@@ -159,12 +148,15 @@ var BaseTileLayer = /*#__PURE__*/function () {
159
148
  key: "getTile",
160
149
  value: function getTile(key) {
161
150
  return this.tileLayerService.getTile(key);
162
- } // 防抖操作
151
+ }
163
152
 
153
+ // 防抖操作
164
154
  }, {
165
155
  key: "tileLoaded",
166
- value: // eslint-disable-next-line @typescript-eslint/no-unused-vars
167
- function tileLoaded(tile) {//
156
+ value:
157
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
+ function tileLoaded(tile) {
159
+ //
168
160
  }
169
161
  }, {
170
162
  key: "tileError",
@@ -175,25 +167,21 @@ var BaseTileLayer = /*#__PURE__*/function () {
175
167
  key: "destroy",
176
168
  value: function destroy() {
177
169
  var _this$tilesetManager3;
178
-
179
170
  this.mapService.off('zoomend', this.mapchange);
180
171
  this.mapService.off('moveend', this.viewchange);
181
172
  (_this$tilesetManager3 = this.tilesetManager) === null || _this$tilesetManager3 === void 0 ? void 0 : _this$tilesetManager3.destroy();
182
173
  this.tileLayerService.destroy();
183
- } // 重新加载
184
-
174
+ }
175
+ // 重新加载
185
176
  }, {
186
177
  key: "reload",
187
178
  value: function reload() {
188
179
  var _this$tilesetManager4;
189
-
190
180
  // 瓦片重新加载
191
181
  this.tilesetManager.clear();
192
-
193
182
  var _this$getCurrentView3 = this.getCurrentView(),
194
- latLonBounds = _this$getCurrentView3.latLonBounds,
195
- zoom = _this$getCurrentView3.zoom;
196
-
183
+ latLonBounds = _this$getCurrentView3.latLonBounds,
184
+ zoom = _this$getCurrentView3.zoom;
197
185
  (_this$tilesetManager4 = this.tilesetManager) === null || _this$tilesetManager4 === void 0 ? void 0 : _this$tilesetManager4.update(zoom, latLonBounds);
198
186
  }
199
187
  }, {
@@ -206,106 +194,84 @@ var BaseTileLayer = /*#__PURE__*/function () {
206
194
  value: function () {
207
195
  var _tileUpdate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
208
196
  var _this3 = this;
209
-
210
197
  var minZoom, maxZoom;
211
198
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
212
- while (1) {
213
- switch (_context2.prev = _context2.next) {
214
- case 0:
215
- if (this.tilesetManager) {
216
- _context2.next = 2;
217
- break;
218
- }
219
-
220
- return _context2.abrupt("return");
221
-
222
- case 2:
223
- minZoom = this.parent.getMinZoom();
224
- maxZoom = this.parent.getMaxZoom();
225
- _context2.next = 6;
226
- return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
227
- return tile.isLoaded;
228
- }) // 过滤未加载完成的
229
- .filter(function (tile) {
230
- return tile.isVisibleChange;
231
- }) // 过滤未发生变化的
232
- .filter(function (tile) {
233
- return tile.data;
234
- }).filter(function (tile) {
235
- return tile.z >= minZoom && tile.z < maxZoom;
236
- }).map( /*#__PURE__*/function () {
237
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile) {
238
- var tileInstance, tileLayer;
239
- return _regeneratorRuntime.wrap(function _callee$(_context) {
240
- while (1) {
241
- switch (_context.prev = _context.next) {
242
- case 0:
243
- if (_this3.tileLayerService.hasTile(tile.key)) {
244
- _context.next = 9;
245
- break;
246
- }
247
-
248
- tileInstance = getTileFactory(_this3.parent);
249
- tileLayer = new tileInstance(tile, _this3.parent);
250
- _context.next = 5;
251
- return tileLayer.initTileLayer();
252
-
253
- case 5:
254
- _this3.tilePickService.setPickState();
255
-
256
- if (tileLayer.getLayers().length !== 0) {
257
- _this3.tileLayerService.addTile(tileLayer);
258
-
259
- _this3.tileLayerService.updateTileVisible(tile);
260
-
261
- _this3.layerService.reRender();
262
- }
263
-
264
- _context.next = 12;
265
- break;
266
-
267
- case 9:
268
- // 已加载瓦片
269
- _this3.tileLayerService.updateTileVisible(tile);
270
-
271
- _this3.tilePickService.setPickState();
272
-
273
- _this3.layerService.reRender();
274
-
275
- case 12:
276
- case "end":
277
- return _context.stop();
199
+ while (1) switch (_context2.prev = _context2.next) {
200
+ case 0:
201
+ if (this.tilesetManager) {
202
+ _context2.next = 2;
203
+ break;
204
+ }
205
+ return _context2.abrupt("return");
206
+ case 2:
207
+ minZoom = this.parent.getMinZoom();
208
+ maxZoom = this.parent.getMaxZoom();
209
+ _context2.next = 6;
210
+ return Promise.all(this.tilesetManager.tiles.filter(function (tile) {
211
+ return tile.isLoaded;
212
+ }) // 过滤未加载完成的
213
+ .filter(function (tile) {
214
+ return tile.isVisibleChange;
215
+ }) // 过滤未发生变化的
216
+ .filter(function (tile) {
217
+ return tile.data;
218
+ }).filter(function (tile) {
219
+ return tile.z >= minZoom && tile.z < maxZoom;
220
+ }).map( /*#__PURE__*/function () {
221
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(tile) {
222
+ var tileInstance, tileLayer;
223
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
224
+ while (1) switch (_context.prev = _context.next) {
225
+ case 0:
226
+ if (_this3.tileLayerService.hasTile(tile.key)) {
227
+ _context.next = 9;
228
+ break;
278
229
  }
279
- }
280
- }, _callee);
281
- }));
282
-
283
- return function (_x) {
284
- return _ref.apply(this, arguments);
285
- };
286
- }()));
287
-
288
- case 6:
289
- if (this.tilesetManager.isLoaded) {
290
- // 将事件抛出,图层上可以使用瓦片
291
- this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
292
- }
293
-
294
- case 7:
295
- case "end":
296
- return _context2.stop();
297
- }
230
+ tileInstance = getTileFactory(_this3.parent);
231
+ tileLayer = new tileInstance(tile, _this3.parent);
232
+ _context.next = 5;
233
+ return tileLayer.initTileLayer();
234
+ case 5:
235
+ _this3.tilePickService.setPickState();
236
+ if (tileLayer.getLayers().length !== 0) {
237
+ _this3.tileLayerService.addTile(tileLayer);
238
+ _this3.tileLayerService.updateTileVisible(tile);
239
+ _this3.layerService.reRender();
240
+ }
241
+ _context.next = 12;
242
+ break;
243
+ case 9:
244
+ // 已加载瓦片
245
+
246
+ _this3.tileLayerService.updateTileVisible(tile);
247
+ _this3.tilePickService.setPickState();
248
+ _this3.layerService.reRender();
249
+ case 12:
250
+ case "end":
251
+ return _context.stop();
252
+ }
253
+ }, _callee);
254
+ }));
255
+ return function (_x) {
256
+ return _ref.apply(this, arguments);
257
+ };
258
+ }()));
259
+ case 6:
260
+ if (this.tilesetManager.isLoaded) {
261
+ // 将事件抛出,图层上可以使用瓦片
262
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
263
+ }
264
+ case 7:
265
+ case "end":
266
+ return _context2.stop();
298
267
  }
299
268
  }, _callee2, this);
300
269
  }));
301
-
302
270
  function tileUpdate() {
303
271
  return _tileUpdate.apply(this, arguments);
304
272
  }
305
-
306
273
  return tileUpdate;
307
274
  }() // eslint-disable-next-line @typescript-eslint/no-unused-vars
308
-
309
275
  }, {
310
276
  key: "setPickState",
311
277
  value: function setPickState(layers) {
@@ -326,46 +292,39 @@ var BaseTileLayer = /*#__PURE__*/function () {
326
292
  value: function highlightPickedFeature(pickedColors) {
327
293
  this.tilePickService.highlightPickedFeature(pickedColors);
328
294
  }
295
+
329
296
  /**
330
297
  * 实现 TileLayer 对子图层方法的代理
331
298
  * @param parent
332
299
  */
333
-
334
300
  }, {
335
301
  key: "proxy",
336
302
  value: function proxy(parent) {
337
303
  var _this4 = this;
338
-
339
304
  ProxyFuncs.forEach(function (func) {
340
305
  // @ts-ignore
341
- var oldStyleFunc = parent[func].bind(parent); // @ts-ignore
342
-
306
+ var oldStyleFunc = parent[func].bind(parent);
307
+ // @ts-ignore
343
308
  parent[func] = function () {
344
309
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
345
310
  args[_key] = arguments[_key];
346
311
  }
347
-
348
312
  oldStyleFunc.apply(void 0, args);
349
-
350
313
  _this4.getLayers().map(function (child) {
351
314
  // @ts-ignore
352
315
  child[func].apply(child, args);
353
- }); // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
354
-
355
-
316
+ });
317
+ // Tip: 目前在更新 RasterData 的 colorTexture 的时候需要额外优化
356
318
  if (func === 'style') {
357
319
  _this4.getTiles().forEach(function (tile) {
358
320
  return tile.styleUpdate.apply(tile, args);
359
321
  });
360
322
  }
361
-
362
323
  return parent;
363
324
  };
364
325
  });
365
326
  }
366
327
  }]);
367
-
368
328
  return BaseTileLayer;
369
329
  }();
370
-
371
330
  export { BaseTileLayer as default };
package/es/tile/utils.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { DOM } from '@antv/l7-utils';
2
2
  export var tileVectorParser = ['mvt', 'geojsonvt', 'testTile'];
3
+
3
4
  /**
4
5
  * 判断当前图层是否是瓦片图层
5
6
  * @param layer
6
7
  * @returns
7
8
  */
8
-
9
9
  export function isTileGroup(layer) {
10
10
  var source = layer.getSource();
11
11
  return tileVectorParser.includes(source.parser.type);
package/es/utils/blend.js CHANGED
@@ -1,7 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
-
3
2
  var _BlendTypes;
4
-
5
3
  import { BlendType, gl } from '@antv/l7-core';
6
4
  export var BlendTypes = (_BlendTypes = {}, _defineProperty(_BlendTypes, BlendType.additive, {
7
5
  enable: true,
@@ -9,24 +9,20 @@ import GridIndex from "./grid-index";
9
9
  * 基于网格实现文本避让,大幅提升包围盒碰撞检测效率
10
10
  * @see https://zhuanlan.zhihu.com/p/74373214
11
11
  */
12
-
13
12
  var CollisionIndex = /*#__PURE__*/function () {
14
13
  function CollisionIndex(width, height) {
15
14
  _classCallCheck(this, CollisionIndex);
16
-
17
15
  _defineProperty(this, "viewportPadding", 100);
18
-
19
16
  this.width = width;
20
17
  this.height = height;
21
- this.viewportPadding = Math.max(width, height); // 创建网格索引
22
-
18
+ this.viewportPadding = Math.max(width, height);
19
+ // 创建网格索引
23
20
  this.grid = new GridIndex(width + this.viewportPadding, height + this.viewportPadding, 25);
24
21
  this.screenRightBoundary = width + this.viewportPadding;
25
22
  this.screenBottomBoundary = height + this.viewportPadding;
26
23
  this.gridRightBoundary = width + 2 * this.viewportPadding;
27
24
  this.gridBottomBoundary = height + 2 * this.viewportPadding;
28
25
  }
29
-
30
26
  _createClass(CollisionIndex, [{
31
27
  key: "placeCollisionBox",
32
28
  value: function placeCollisionBox(collisionBox) {
@@ -35,17 +31,16 @@ var CollisionIndex = /*#__PURE__*/function () {
35
31
  // collisionBox.anchorPointX,
36
32
  // collisionBox.anchorPointY,
37
33
  // );
34
+
38
35
  var tlX = collisionBox.x1 + collisionBox.anchorPointX + this.viewportPadding;
39
36
  var tlY = collisionBox.y1 + collisionBox.anchorPointY + this.viewportPadding;
40
37
  var brX = collisionBox.x2 + collisionBox.anchorPointX + this.viewportPadding;
41
38
  var brY = collisionBox.y2 + collisionBox.anchorPointY + this.viewportPadding;
42
-
43
39
  if (!this.isInsideGrid(tlX, tlY, brX, brY) || this.grid.hitTest(tlX, tlY, brX, brY)) {
44
40
  return {
45
41
  box: []
46
42
  };
47
43
  }
48
-
49
44
  return {
50
45
  box: [tlX, tlY, brX, brY]
51
46
  };
@@ -58,6 +53,7 @@ var CollisionIndex = /*#__PURE__*/function () {
58
53
  };
59
54
  this.grid.insert(key, box[0], box[1], box[2], box[3]);
60
55
  }
56
+
61
57
  /**
62
58
  * 后续碰撞检测都需要投影到 viewport 坐标系
63
59
  * @param {THREE.Matrix4} mvpMatrix mvp矩阵
@@ -65,21 +61,21 @@ var CollisionIndex = /*#__PURE__*/function () {
65
61
  * @param {number} y P20 平面坐标Y
66
62
  * @return {Point} projectedPoint
67
63
  */
68
-
69
64
  }, {
70
65
  key: "project",
71
66
  value: function project(mvpMatrix, x, y) {
72
67
  var point = vec4.fromValues(x, y, 0, 1);
73
- var out = vec4.create(); // @ts-ignore
74
-
68
+ var out = vec4.create();
69
+ // @ts-ignore
75
70
  var mat = mat4.fromValues.apply(mat4, _toConsumableArray(mvpMatrix));
76
- vec4.transformMat4(out, point, mat); // GL 坐标系[-1, 1] -> viewport 坐标系[width, height]
77
-
71
+ vec4.transformMat4(out, point, mat);
72
+ // GL 坐标系[-1, 1] -> viewport 坐标系[width, height]
78
73
  return {
79
74
  x: (out[0] / out[3] + 1) / 2 * this.width + this.viewportPadding,
80
75
  y: (-out[1] / out[3] + 1) / 2 * this.height + this.viewportPadding
81
76
  };
82
77
  }
78
+
83
79
  /**
84
80
  * 判断包围盒是否在整个网格内,需要加上 buffer
85
81
  * @param {number} x1 x1
@@ -88,15 +84,12 @@ var CollisionIndex = /*#__PURE__*/function () {
88
84
  * @param {number} y2 y2
89
85
  * @return {Point} isInside
90
86
  */
91
-
92
87
  }, {
93
88
  key: "isInsideGrid",
94
89
  value: function isInsideGrid(x1, y1, x2, y2) {
95
90
  return x2 >= 0 && x1 < this.gridRightBoundary && y2 >= 0 && y1 < this.gridBottomBoundary;
96
91
  }
97
92
  }]);
98
-
99
93
  return CollisionIndex;
100
94
  }();
101
-
102
95
  export { CollisionIndex as default };