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