@antv/l7-layers 2.9.23 → 2.9.25

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 (166) hide show
  1. package/es/Geometry/models/plane.d.ts +1 -0
  2. package/es/citybuliding/building.js +1 -1
  3. package/es/core/BaseLayer.js +10 -3
  4. package/es/core/interface.d.ts +26 -48
  5. package/es/core/interface.js +3 -0
  6. package/es/core/schema.d.ts +3 -3
  7. package/es/core/triangulation.d.ts +4 -3
  8. package/es/core/triangulation.js +54 -39
  9. package/es/heatmap/models/heatmap.js +1 -1
  10. package/es/image/models/image.js +7 -1
  11. package/es/line/index.js +4 -1
  12. package/es/line/models/arc.js +1 -1
  13. package/es/line/models/simpleLine.js +1 -1
  14. package/es/line/shaders/line_arc_vert.glsl +5 -3
  15. package/es/line/shaders/simple/simpleline_vert.glsl +1 -0
  16. package/es/plugins/FeatureScalePlugin.js +0 -1
  17. package/es/point/index.js +3 -1
  18. package/es/point/models/fill.js +5 -2
  19. package/es/point/models/fillmage.js +9 -3
  20. package/es/point/models/image.js +8 -2
  21. package/es/point/models/radar.js +2 -3
  22. package/es/point/models/tile.js +1 -1
  23. package/es/point/shaders/fill_vert.glsl +13 -6
  24. package/es/point/shaders/image/fillImage_vert.glsl +13 -5
  25. package/es/point/shaders/image_vert.glsl +17 -8
  26. package/es/polygon/index.js +4 -1
  27. package/es/raster/index.js +3 -1
  28. package/es/tile/manager/tileLayerManager.d.ts +3 -2
  29. package/es/tile/manager/tileLayerManager.js +5 -2
  30. package/es/tile/models/tileModel.js +4 -3
  31. package/es/tile/tileFactory/base.d.ts +1 -1
  32. package/es/tile/tileFactory/base.js +32 -5
  33. package/es/tile/tileFactory/vectorLayer.d.ts +3 -1
  34. package/es/tile/tileFactory/vectorLayer.js +22 -1
  35. package/es/tile/tileLayer/baseTileLayer.d.ts +1 -1
  36. package/es/tile/tileLayer/baseTileLayer.js +3 -2
  37. package/es/tile/utils.d.ts +2 -0
  38. package/es/tile/utils.js +5 -1
  39. package/lib/Geometry/index.js +114 -77
  40. package/lib/Geometry/models/billboard.js +232 -181
  41. package/lib/Geometry/models/index.js +18 -34
  42. package/lib/Geometry/models/plane.js +407 -278
  43. package/lib/Geometry/models/sprite.js +291 -189
  44. package/lib/canvas/index.js +101 -66
  45. package/lib/canvas/models/canvas.js +207 -140
  46. package/lib/canvas/models/index.js +12 -30
  47. package/lib/citybuliding/building.js +98 -63
  48. package/lib/citybuliding/models/build.js +192 -146
  49. package/lib/core/BaseLayer.js +1331 -809
  50. package/lib/core/BaseModel.js +457 -279
  51. package/lib/core/interface.js +40 -53
  52. package/lib/core/schema.js +21 -39
  53. package/lib/core/shape/Path.js +67 -79
  54. package/lib/core/shape/extrude.js +132 -91
  55. package/lib/core/triangulation.js +412 -213
  56. package/lib/earth/index.js +100 -62
  57. package/lib/earth/models/atmosphere.js +146 -112
  58. package/lib/earth/models/base.js +210 -150
  59. package/lib/earth/models/bloomsphere.js +146 -112
  60. package/lib/earth/utils.js +111 -91
  61. package/lib/heatmap/index.js +149 -92
  62. package/lib/heatmap/models/grid.js +118 -91
  63. package/lib/heatmap/models/grid3d.js +155 -123
  64. package/lib/heatmap/models/heatmap.js +475 -338
  65. package/lib/heatmap/models/hexagon.js +121 -92
  66. package/lib/heatmap/models/index.js +22 -37
  67. package/lib/heatmap/triangulation.js +31 -47
  68. package/lib/image/index.js +111 -74
  69. package/lib/image/models/dataImage.js +232 -174
  70. package/lib/image/models/image.js +175 -123
  71. package/lib/image/models/index.js +15 -32
  72. package/lib/index.js +263 -97
  73. package/lib/line/index.js +131 -83
  74. package/lib/line/models/arc.js +352 -237
  75. package/lib/line/models/arc_3d.js +334 -228
  76. package/lib/line/models/earthArc_3d.js +336 -228
  77. package/lib/line/models/great_circle.js +291 -200
  78. package/lib/line/models/half.js +286 -201
  79. package/lib/line/models/index.js +42 -50
  80. package/lib/line/models/line.js +428 -299
  81. package/lib/line/models/linearline.js +277 -203
  82. package/lib/line/models/simpleLine.js +239 -175
  83. package/lib/line/models/tile.js +348 -237
  84. package/lib/line/models/wall.js +327 -235
  85. package/lib/line/shaders/line_arc_vert.glsl +5 -3
  86. package/lib/line/shaders/simple/simpleline_vert.glsl +1 -0
  87. package/lib/mask/index.js +92 -59
  88. package/lib/mask/models/fill.js +134 -82
  89. package/lib/mask/models/index.js +12 -30
  90. package/lib/plugins/DataMappingPlugin.js +342 -224
  91. package/lib/plugins/DataSourcePlugin.js +102 -87
  92. package/lib/plugins/FeatureScalePlugin.js +330 -241
  93. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  94. package/lib/plugins/LayerModelPlugin.js +80 -73
  95. package/lib/plugins/LayerStylePlugin.js +48 -51
  96. package/lib/plugins/LightingPlugin.js +80 -68
  97. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  98. package/lib/plugins/PixelPickingPlugin.js +150 -109
  99. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  100. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  101. package/lib/plugins/UpdateModelPlugin.js +40 -47
  102. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  103. package/lib/point/index.js +226 -148
  104. package/lib/point/models/earthExtrude.js +279 -201
  105. package/lib/point/models/earthFill.js +287 -202
  106. package/lib/point/models/extrude.js +299 -203
  107. package/lib/point/models/fill.js +406 -273
  108. package/lib/point/models/fillmage.js +365 -252
  109. package/lib/point/models/image.js +241 -164
  110. package/lib/point/models/index.js +46 -52
  111. package/lib/point/models/normal.js +183 -134
  112. package/lib/point/models/radar.js +304 -212
  113. package/lib/point/models/simplePoint.js +194 -142
  114. package/lib/point/models/text.js +608 -385
  115. package/lib/point/models/tile.js +314 -223
  116. package/lib/point/shaders/fill_vert.glsl +13 -6
  117. package/lib/point/shaders/image/fillImage_vert.glsl +13 -5
  118. package/lib/point/shaders/image_vert.glsl +17 -8
  119. package/lib/point/shape/extrude.js +56 -52
  120. package/lib/polygon/index.js +154 -100
  121. package/lib/polygon/models/extrude.js +311 -223
  122. package/lib/polygon/models/fill.js +215 -153
  123. package/lib/polygon/models/index.js +46 -52
  124. package/lib/polygon/models/ocean.js +244 -173
  125. package/lib/polygon/models/tile.js +144 -100
  126. package/lib/polygon/models/water.js +222 -153
  127. package/lib/raster/buffers/triangulation.js +27 -40
  128. package/lib/raster/index.js +115 -74
  129. package/lib/raster/models/index.js +16 -33
  130. package/lib/raster/models/raster.js +178 -135
  131. package/lib/raster/raster.js +187 -132
  132. package/lib/tile/interface.js +4 -16
  133. package/lib/tile/manager/tileConfigManager.js +125 -86
  134. package/lib/tile/manager/tileLayerManager.js +314 -227
  135. package/lib/tile/manager/tilePickerManager.js +192 -123
  136. package/lib/tile/models/tileModel.js +71 -51
  137. package/lib/tile/tileFactory/base.js +433 -292
  138. package/lib/tile/tileFactory/index.js +51 -49
  139. package/lib/tile/tileFactory/line.js +65 -50
  140. package/lib/tile/tileFactory/point.js +65 -50
  141. package/lib/tile/tileFactory/polygon.js +65 -50
  142. package/lib/tile/tileFactory/raster.js +66 -54
  143. package/lib/tile/tileFactory/rasterData.js +88 -76
  144. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  145. package/lib/tile/tileFactory/vectorLayer.js +169 -95
  146. package/lib/tile/tileLayer/baseTileLayer.js +420 -220
  147. package/lib/tile/tmsTileLayer.js +110 -67
  148. package/lib/tile/utils.js +113 -87
  149. package/lib/utils/blend.js +59 -79
  150. package/lib/utils/collision-index.js +107 -64
  151. package/lib/utils/dataMappingStyle.js +105 -60
  152. package/lib/utils/extrude_polyline.js +600 -398
  153. package/lib/utils/grid-index.js +163 -111
  154. package/lib/utils/layerData.js +130 -99
  155. package/lib/utils/multiPassRender.js +49 -41
  156. package/lib/utils/polylineNormal.js +148 -96
  157. package/lib/utils/simpleLine.js +100 -85
  158. package/lib/utils/symbol-layout.js +219 -116
  159. package/lib/utils/updateShape.js +15 -41
  160. package/lib/wind/index.js +109 -71
  161. package/lib/wind/models/index.js +12 -30
  162. package/lib/wind/models/utils.js +144 -105
  163. package/lib/wind/models/wind.js +333 -224
  164. package/lib/wind/models/windRender.js +329 -218
  165. package/lib/wind/models/windShader.js +23 -181
  166. package/package.json +7 -6
@@ -1,247 +1,447 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // src/tile/tileLayer/baseTileLayer.ts
20
- var baseTileLayer_exports = {};
21
- __export(baseTileLayer_exports, {
22
- default: () => BaseTileLayer
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
23
7
  });
24
- module.exports = __toCommonJS(baseTileLayer_exports);
25
- var import_l7_utils = require("@antv/l7-utils");
26
- var import_tileLayerManager = require("../manager/tileLayerManager");
27
- var BaseTileLayer = class {
28
- constructor({
29
- parent,
30
- rendererService,
31
- mapService,
32
- layerService,
33
- pickingService
34
- }) {
35
- this.type = "baseTile";
36
- this.initedTileset = false;
37
- this.pickColors = {
8
+ exports.default = void 0;
9
+
10
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
+
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
15
+
16
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
17
+
18
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
+
20
+ var _l7Utils = require("@antv/l7-utils");
21
+
22
+ var _tileLayerManager = require("../manager/tileLayerManager");
23
+
24
+ var BaseTileLayer = /*#__PURE__*/function () {
25
+ function BaseTileLayer(_ref) {
26
+ var _parentSource$data;
27
+
28
+ var parent = _ref.parent,
29
+ rendererService = _ref.rendererService,
30
+ mapService = _ref.mapService,
31
+ layerService = _ref.layerService,
32
+ pickingService = _ref.pickingService,
33
+ transforms = _ref.transforms;
34
+ (0, _classCallCheck2.default)(this, BaseTileLayer);
35
+ (0, _defineProperty2.default)(this, "type", 'baseTile');
36
+ (0, _defineProperty2.default)(this, "initedTileset", false);
37
+ (0, _defineProperty2.default)(this, "pickColors", {
38
38
  select: null,
39
39
  active: null
40
- };
41
- var _a;
42
- const parentSource = parent.getSource();
43
- const { sourceLayer, coords, featureId } = ((_a = parentSource == null ? void 0 : parentSource.data) == null ? void 0 : _a.tilesetOptions) || {};
40
+ });
41
+ var parentSource = parent.getSource();
42
+
43
+ var _ref2 = (parentSource === null || parentSource === void 0 ? void 0 : (_parentSource$data = parentSource.data) === null || _parentSource$data === void 0 ? void 0 : _parentSource$data.tilesetOptions) || {},
44
+ sourceLayer = _ref2.sourceLayer,
45
+ coords = _ref2.coords,
46
+ featureId = _ref2.featureId;
47
+
44
48
  this.sourceLayer = sourceLayer;
45
49
  this.parent = parent;
46
50
  this.mapService = mapService;
47
51
  this.layerService = layerService;
48
- this.tileLayerManager = new import_tileLayerManager.TileLayerManager(parent, mapService, rendererService, pickingService, layerService);
52
+ this.tileLayerManager = new _tileLayerManager.TileLayerManager(parent, mapService, rendererService, pickingService, layerService, transforms);
49
53
  this.initTileSetManager();
50
54
  this.bindSubLayerEvent();
51
55
  this.bindSubLayerPick();
52
56
  this.scaleField = this.parent.getScaleOptions();
53
57
  }
54
- get children() {
55
- return this.tileLayerManager.children;
56
- }
57
- render() {
58
- if (this.tileLayerManager) {
59
- this.tileLayerManager.render();
58
+ /**
59
+ * 渲染瓦片的图层
60
+ */
61
+
62
+
63
+ (0, _createClass2.default)(BaseTileLayer, [{
64
+ key: "children",
65
+ get: function get() {
66
+ return this.tileLayerManager.children;
60
67
  }
61
- }
62
- clearPick(type) {
63
- if (type === "mousemove") {
64
- this.tileLayerManager.tilePickManager.clearPick();
68
+ }, {
69
+ key: "render",
70
+ value: function render() {
71
+ if (this.tileLayerManager) {
72
+ this.tileLayerManager.render();
73
+ }
65
74
  }
66
- }
67
- clearPickState() {
68
- this.children.filter((child) => child.inited && child.isVisible()).filter((child) => child.getCurrentSelectedId() !== null).map((child) => {
69
- this.selectFeature(child, new Uint8Array([0, 0, 0, 0]));
70
- child.setCurrentSelectedId(null);
71
- });
72
- }
73
- pickLayers(target) {
74
- return this.tileLayerManager.pickLayers(target);
75
- }
76
- tileLoaded(tile) {
77
- }
78
- tileError(error) {
79
- console.warn("error:", error);
80
- }
81
- tileUnLoad(tile) {
82
- this.tileLayerManager.removeChilds(tile.layerIDList, false);
83
- }
84
- tileUpdate() {
85
- if (!this.tilesetManager) {
86
- return;
87
- }
88
- this.tilesetManager.tiles.filter((tile) => tile.isLoaded).map((tile) => {
89
- if (tile.layerIDList.length === 0) {
90
- const { layers, layerIDList } = this.tileLayerManager.createTile(tile);
91
- tile.layerIDList = layerIDList;
92
- this.tileLayerManager.addChilds(layers);
93
- } else {
94
- if (!tile.isVisibleChange) {
95
- return;
96
- }
97
- const layers = this.tileLayerManager.getChilds(tile.layerIDList);
98
- this.tileLayerManager.updateLayersConfig(layers, "visible", tile.isVisible);
75
+ }, {
76
+ key: "clearPick",
77
+ value: function clearPick(type) {
78
+ if (type === 'mousemove') {
79
+ this.tileLayerManager.tilePickManager.clearPick();
99
80
  }
100
- });
101
- if (this.tilesetManager.isLoaded) {
102
- this.parent.emit("tiles-loaded", this.tilesetManager.currentTiles);
103
81
  }
104
- }
105
- setPickState(layers) {
106
- if (this.pickColors.select) {
107
- const selectedId = (0, import_l7_utils.decodePickingColor)(this.pickColors.select);
108
- layers.map((layer) => {
109
- this.selectFeature(layer, this.pickColors.select);
110
- layer.setCurrentSelectedId(selectedId);
82
+ /**
83
+ * 清除 select 的选中状态
84
+ */
85
+
86
+ }, {
87
+ key: "clearPickState",
88
+ value: function clearPickState() {
89
+ var _this = this;
90
+
91
+ this.children.filter(function (child) {
92
+ return child.inited && child.isVisible();
93
+ }).filter(function (child) {
94
+ return child.getCurrentSelectedId() !== null;
95
+ }).map(function (child) {
96
+ _this.selectFeature(child, new Uint8Array([0, 0, 0, 0]));
97
+
98
+ child.setCurrentSelectedId(null);
111
99
  });
112
100
  }
113
- if (this.pickColors.active) {
114
- const selectedId = (0, import_l7_utils.decodePickingColor)(this.pickColors.active);
115
- layers.filter((layer) => layer.inited && layer.isVisible()).map((layer) => {
116
- layer.hooks.beforeHighlight.call(this.pickColors.active);
117
- layer.setCurrentPickId(selectedId);
101
+ /**
102
+ * 瓦片图层独立的拾取逻辑
103
+ * @param target
104
+ * @returns
105
+ */
106
+
107
+ }, {
108
+ key: "pickLayers",
109
+ value: function pickLayers(target) {
110
+ return this.tileLayerManager.pickLayers(target);
111
+ }
112
+ }, {
113
+ key: "tileLoaded",
114
+ value: function tileLoaded(tile) {//
115
+ }
116
+ }, {
117
+ key: "tileError",
118
+ value: function tileError(error) {
119
+ console.warn('error:', error);
120
+ }
121
+ }, {
122
+ key: "tileUnLoad",
123
+ value: function tileUnLoad(tile) {
124
+ this.tileLayerManager.removeChilds(tile.layerIDList, false);
125
+ }
126
+ }, {
127
+ key: "tileUpdate",
128
+ value: function tileUpdate() {
129
+ var _this2 = this;
130
+
131
+ // Base Function
132
+ if (!this.tilesetManager) {
133
+ return;
134
+ }
135
+
136
+ this.tilesetManager.tiles.filter(function (tile) {
137
+ return tile.isLoaded;
138
+ }).map(function (tile) {
139
+ if (tile.layerIDList.length === 0) {
140
+ var _this2$tileLayerManag = _this2.tileLayerManager.createTile(tile),
141
+ layers = _this2$tileLayerManag.layers,
142
+ layerIDList = _this2$tileLayerManag.layerIDList;
143
+
144
+ tile.layerIDList = layerIDList;
145
+
146
+ _this2.tileLayerManager.addChilds(layers);
147
+ } else {
148
+ if (!tile.isVisibleChange) {
149
+ return;
150
+ }
151
+
152
+ var _layers = _this2.tileLayerManager.getChilds(tile.layerIDList);
153
+
154
+ _this2.tileLayerManager.updateLayersConfig(_layers, 'visible', tile.isVisible);
155
+ }
118
156
  });
157
+
158
+ if (this.tilesetManager.isLoaded) {
159
+ // 将事件抛出,图层上可以使用瓦片
160
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
161
+ }
119
162
  }
120
- }
121
- bindSubLayerPick() {
122
- this.tileLayerManager.tilePickManager.on("pick", (e) => {
123
- const [r, g, b] = e.pickedColors;
124
- if (e.type === "click") {
125
- const restLayers = this.children.filter((child) => child.inited && child.isVisible() && child.isVector).filter((child) => child !== e.layer);
126
- this.setSelect(restLayers, [r, g, b]);
127
- } else {
128
- this.setHighlight([r, g, b]);
163
+ }, {
164
+ key: "setPickState",
165
+ value: function setPickState(layers) {
166
+ var _this3 = this;
167
+
168
+ if (this.pickColors.select) {
169
+ var selectedId = (0, _l7Utils.decodePickingColor)(this.pickColors.select);
170
+ layers.map(function (layer) {
171
+ _this3.selectFeature(layer, _this3.pickColors.select);
172
+
173
+ layer.setCurrentSelectedId(selectedId);
174
+ });
129
175
  }
130
- });
131
- this.tileLayerManager.tilePickManager.on("unpick", () => {
132
- this.pickColors.active = null;
133
- });
134
- }
135
- setHighlight(pickedColors) {
136
- const pickId = (0, import_l7_utils.decodePickingColor)(pickedColors);
137
- this.pickColors.active = pickedColors;
138
- this.children.filter((child) => child.inited && child.isVisible() && child.isVector).filter((child) => child.getPickID() !== pickId).map((child) => {
139
- child.setPickID(pickId);
140
- child.hooks.beforeHighlight.call(pickedColors);
141
- });
142
- }
143
- setSelect(layers, pickedColors) {
144
- const selectedId = (0, import_l7_utils.decodePickingColor)(pickedColors);
145
- layers.map((layer) => {
146
- if (layer.getCurrentSelectedId() === null || selectedId !== layer.getCurrentSelectedId()) {
147
- this.selectFeature(layer, pickedColors);
148
- layer.setCurrentSelectedId(selectedId);
149
- this.pickColors.select = pickedColors;
150
- } else {
151
- this.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
152
- layer.setCurrentSelectedId(null);
153
- this.pickColors.select = null;
176
+
177
+ if (this.pickColors.active) {
178
+ var _selectedId = (0, _l7Utils.decodePickingColor)(this.pickColors.active);
179
+
180
+ layers.filter(function (layer) {
181
+ return layer.inited && layer.isVisible();
182
+ }).map(function (layer) {
183
+ layer.hooks.beforeHighlight.call(_this3.pickColors.active);
184
+ layer.setCurrentPickId(_selectedId);
185
+ });
154
186
  }
155
- });
156
- const renderList = this.layerService.getRenderList();
157
- renderList.filter((layer) => layer.inited && !layer.isVector && layer.isVisible() && layer.needPick("click")).filter((layer) => layer.getCurrentSelectedId() !== null).map((layer) => {
158
- this.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
159
- layer.setCurrentSelectedId(null);
160
- });
161
- }
162
- selectFeature(layer, pickedColors) {
163
- const [r, g, b] = pickedColors;
164
- layer.hooks.beforeSelect.call([r, g, b]);
165
- }
166
- bindSubLayerEvent() {
167
- this.parent.on("subLayerClick", (e) => {
168
- this.parent.emit("click", { ...e });
169
- });
170
- this.parent.on("subLayerMouseMove", (e) => this.parent.emit("mousemove", { ...e }));
171
- this.parent.on("subLayerMouseUp", (e) => this.parent.emit("mouseup", { ...e }));
172
- this.parent.on("subLayerMouseEnter", (e) => this.parent.emit("mouseenter", { ...e }));
173
- this.parent.on("subLayerMouseOut", (e) => this.parent.emit("mouseout", { ...e }));
174
- this.parent.on("subLayerMouseDown", (e) => this.parent.emit("mousedown", { ...e }));
175
- this.parent.on("subLayerContextmenu", (e) => this.parent.emit("contextmenu", { ...e }));
176
- this.parent.on("subLayerUnClick", (e) => this.parent.emit("unclick", { ...e }));
177
- this.parent.on("subLayerUnMouseMove", (e) => this.parent.emit("unmousemove", { ...e }));
178
- this.parent.on("subLayerUnMouseUp", (e) => this.parent.emit("unmouseup", { ...e }));
179
- this.parent.on("subLayerUnMouseDown", (e) => this.parent.emit("unmousedown", { ...e }));
180
- this.parent.on("subLayerUnContextmenu", (e) => this.parent.emit("uncontextmenu", { ...e }));
181
- }
182
- initTileSetManager() {
183
- var _a;
184
- const source = this.parent.getSource();
185
- this.tilesetManager = source.tileset;
186
- if (!this.initedTileset) {
187
- this.bindTilesetEvent();
188
- this.initedTileset = true;
189
- }
190
- const { latLonBounds, zoom } = this.getCurrentView();
191
- (_a = this.tilesetManager) == null ? void 0 : _a.update(zoom, latLonBounds);
192
- }
193
- mapchange() {
194
- var _a;
195
- const { latLonBounds, zoom } = this.getCurrentView();
196
- if (this.mapService.version === "GAODE1.x") {
197
- const { visible } = this.parent.getLayerConfig();
198
- if (zoom < 3 && visible) {
199
- this.parent.updateLayerConfig({ visible: false });
200
- this.layerService.updateLayerRenderList();
201
- } else if (zoom >= 3 && !visible) {
202
- this.parent.updateLayerConfig({ visible: true });
203
- this.layerService.updateLayerRenderList();
187
+ }
188
+ }, {
189
+ key: "bindSubLayerPick",
190
+ value: function bindSubLayerPick() {
191
+ var _this4 = this;
192
+
193
+ this.tileLayerManager.tilePickManager.on('pick', function (e) {
194
+ // @ts-ignore
195
+ var _e$pickedColors = (0, _slicedToArray2.default)(e.pickedColors, 3),
196
+ r = _e$pickedColors[0],
197
+ g = _e$pickedColors[1],
198
+ b = _e$pickedColors[2];
199
+
200
+ if (e.type === 'click') {
201
+ var restLayers = _this4.children.filter(function (child) {
202
+ return child.inited && child.isVisible() && child.isVector;
203
+ }).filter(function (child) {
204
+ return child !== e.layer;
205
+ });
206
+
207
+ _this4.setSelect(restLayers, [r, g, b]);
208
+ } else {
209
+ _this4.setHighlight([r, g, b]);
210
+ }
211
+ });
212
+ this.tileLayerManager.tilePickManager.on('unpick', function () {
213
+ _this4.pickColors.active = null;
214
+ });
215
+ }
216
+ }, {
217
+ key: "setHighlight",
218
+ value: function setHighlight(pickedColors) {
219
+ var pickId = (0, _l7Utils.decodePickingColor)(pickedColors);
220
+ this.pickColors.active = pickedColors;
221
+ this.children.filter(function (child) {
222
+ return child.inited && child.isVisible() && child.isVector;
223
+ }) // Tip: 使用 vectorLayer 上的 pickID 优化高亮操作(过滤重复操作)
224
+ // @ts-ignore
225
+ .filter(function (child) {
226
+ return child.getPickID() !== pickId;
227
+ }).map(function (child) {
228
+ // @ts-ignore
229
+ child.setPickID(pickId);
230
+ child.hooks.beforeHighlight.call(pickedColors);
231
+ });
232
+ }
233
+ }, {
234
+ key: "setSelect",
235
+ value: function setSelect(layers, pickedColors) {
236
+ var _this5 = this;
237
+
238
+ var selectedId = (0, _l7Utils.decodePickingColor)(pickedColors);
239
+ layers.map(function (layer) {
240
+ if (layer.getCurrentSelectedId() === null || selectedId !== layer.getCurrentSelectedId()) {
241
+ _this5.selectFeature(layer, pickedColors);
242
+
243
+ layer.setCurrentSelectedId(selectedId);
244
+ _this5.pickColors.select = pickedColors;
245
+ } else {
246
+ _this5.selectFeature(layer, new Uint8Array([0, 0, 0, 0])); // toggle select
247
+
248
+
249
+ layer.setCurrentSelectedId(null);
250
+ _this5.pickColors.select = null;
251
+ }
252
+ }); // unselect normal layer
253
+
254
+ var renderList = this.layerService.getRenderList();
255
+ renderList.filter(function (layer) {
256
+ return layer.inited && !layer.isVector && layer.isVisible() && layer.needPick('click');
257
+ }).filter(function (layer) {
258
+ return layer.getCurrentSelectedId() !== null;
259
+ }).map(function (layer) {
260
+ _this5.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
261
+
262
+ layer.setCurrentSelectedId(null);
263
+ });
264
+ }
265
+ }, {
266
+ key: "selectFeature",
267
+ value: function selectFeature(layer, pickedColors) {
268
+ // @ts-ignore
269
+ var _pickedColors = (0, _slicedToArray2.default)(pickedColors, 3),
270
+ r = _pickedColors[0],
271
+ g = _pickedColors[1],
272
+ b = _pickedColors[2];
273
+
274
+ layer.hooks.beforeSelect.call([r, g, b]);
275
+ }
276
+ }, {
277
+ key: "bindSubLayerEvent",
278
+ value: function bindSubLayerEvent() {
279
+ var _this6 = this;
280
+
281
+ /**
282
+ * layer.on('click', (ev) => {}); // 鼠标左键点击图层事件
283
+ * layer.on('mouseenter', (ev) => {}); // 鼠标进入图层要素
284
+ * layer.on('mousemove', (ev) => {}); // 鼠标在图层上移动时触发
285
+ * layer.on('mouseout', (ev) => {}); // 鼠标移出图层要素时触发
286
+ * layer.on('mouseup', (ev) => {}); // 鼠标在图层上单击抬起时触发
287
+ * layer.on('mousedown', (ev) => {}); // 鼠标在图层上单击按下时触发
288
+ * layer.on('contextmenu', (ev) => {}); // 图层要素点击右键菜单
289
+ *
290
+ * 鼠标在图层外的事件
291
+ * layer.on('unclick', (ev) => {}); // 图层外点击
292
+ * layer.on('unmousemove', (ev) => {}); // 图层外移动
293
+ * layer.on('unmouseup', (ev) => {}); // 图层外鼠标抬起
294
+ * layer.on('unmousedown', (ev) => {}); // 图层外单击按下时触发
295
+ * layer.on('uncontextmenu', (ev) => {}); // 图层外点击右键
296
+ * layer.on('unpick', (ev) => {}); // 图层外的操作的所有事件
297
+ */
298
+ this.parent.on('subLayerClick', function (e) {
299
+ _this6.parent.emit('click', (0, _objectSpread2.default)({}, e));
300
+ });
301
+ this.parent.on('subLayerMouseMove', function (e) {
302
+ return _this6.parent.emit('mousemove', (0, _objectSpread2.default)({}, e));
303
+ });
304
+ this.parent.on('subLayerMouseUp', function (e) {
305
+ return _this6.parent.emit('mouseup', (0, _objectSpread2.default)({}, e));
306
+ });
307
+ this.parent.on('subLayerMouseEnter', function (e) {
308
+ return _this6.parent.emit('mouseenter', (0, _objectSpread2.default)({}, e));
309
+ });
310
+ this.parent.on('subLayerMouseOut', function (e) {
311
+ return _this6.parent.emit('mouseout', (0, _objectSpread2.default)({}, e));
312
+ });
313
+ this.parent.on('subLayerMouseDown', function (e) {
314
+ return _this6.parent.emit('mousedown', (0, _objectSpread2.default)({}, e));
315
+ });
316
+ this.parent.on('subLayerContextmenu', function (e) {
317
+ return _this6.parent.emit('contextmenu', (0, _objectSpread2.default)({}, e));
318
+ }); // vector layer 图层外事件
319
+
320
+ this.parent.on('subLayerUnClick', function (e) {
321
+ return _this6.parent.emit('unclick', (0, _objectSpread2.default)({}, e));
322
+ });
323
+ this.parent.on('subLayerUnMouseMove', function (e) {
324
+ return _this6.parent.emit('unmousemove', (0, _objectSpread2.default)({}, e));
325
+ });
326
+ this.parent.on('subLayerUnMouseUp', function (e) {
327
+ return _this6.parent.emit('unmouseup', (0, _objectSpread2.default)({}, e));
328
+ });
329
+ this.parent.on('subLayerUnMouseDown', function (e) {
330
+ return _this6.parent.emit('unmousedown', (0, _objectSpread2.default)({}, e));
331
+ });
332
+ this.parent.on('subLayerUnContextmenu', function (e) {
333
+ return _this6.parent.emit('uncontextmenu', (0, _objectSpread2.default)({}, e));
334
+ });
335
+ }
336
+ }, {
337
+ key: "initTileSetManager",
338
+ value: function initTileSetManager() {
339
+ var _this$tilesetManager;
340
+
341
+ var source = this.parent.getSource();
342
+ this.tilesetManager = source.tileset;
343
+
344
+ if (!this.initedTileset) {
345
+ this.bindTilesetEvent();
346
+ this.initedTileset = true;
204
347
  }
348
+
349
+ var _this$getCurrentView = this.getCurrentView(),
350
+ latLonBounds = _this$getCurrentView.latLonBounds,
351
+ zoom = _this$getCurrentView.zoom;
352
+
353
+ (_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
205
354
  }
206
- if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
207
- return;
355
+ }, {
356
+ key: "mapchange",
357
+ value: function mapchange() {
358
+ var _this$tilesetManager2;
359
+
360
+ var _this$getCurrentView2 = this.getCurrentView(),
361
+ latLonBounds = _this$getCurrentView2.latLonBounds,
362
+ zoom = _this$getCurrentView2.zoom;
363
+
364
+ if (this.mapService.version === 'GAODE1.x') {
365
+ var _this$parent$getLayer = this.parent.getLayerConfig(),
366
+ visible = _this$parent$getLayer.visible;
367
+
368
+ if (zoom < 3 && visible) {
369
+ this.parent.updateLayerConfig({
370
+ visible: false
371
+ });
372
+ this.layerService.updateLayerRenderList();
373
+ } else if (zoom >= 3 && !visible) {
374
+ this.parent.updateLayerConfig({
375
+ visible: true
376
+ });
377
+ this.layerService.updateLayerRenderList();
378
+ }
379
+ }
380
+
381
+ if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
382
+ return;
383
+ }
384
+
385
+ this.lastViewStates = {
386
+ zoom: zoom,
387
+ latLonBounds: latLonBounds
388
+ };
389
+
390
+ if (this.timer) {
391
+ clearTimeout(this.timer);
392
+ this.timer = null;
393
+ } // this.timer = setTimeout(() => {
394
+
395
+
396
+ (_this$tilesetManager2 = this.tilesetManager) === null || _this$tilesetManager2 === void 0 ? void 0 : _this$tilesetManager2.update(zoom, latLonBounds); // }, 250);
208
397
  }
209
- this.lastViewStates = { zoom, latLonBounds };
210
- if (this.timer) {
211
- clearTimeout(this.timer);
212
- this.timer = null;
398
+ }, {
399
+ key: "bindTilesetEvent",
400
+ value: function bindTilesetEvent() {
401
+ var _this7 = this;
402
+
403
+ if (!this.tilesetManager) {
404
+ return;
405
+ } // 瓦片数据加载成功
406
+
407
+
408
+ this.tilesetManager.on('tile-loaded', function (tile) {// todo: 将事件抛出,图层上可以监听使用
409
+ }); // 瓦片数据从缓存删除或被执行重新加载
410
+
411
+ this.tilesetManager.on('tile-unload', function (tile) {
412
+ // todo: 将事件抛出,图层上可以监听使用
413
+ _this7.tileUnLoad(tile);
414
+ }); // 瓦片数据加载失败
415
+
416
+ this.tilesetManager.on('tile-error', function (error, tile) {
417
+ // todo: 将事件抛出,图层上可以监听使用
418
+ _this7.tileError(error);
419
+ }); // 瓦片显隐状态更新
420
+
421
+ this.tilesetManager.on('tile-update', function () {
422
+ _this7.tileUpdate();
423
+ }); // 地图视野发生改变
424
+
425
+ this.mapService.on('zoomend', function () {
426
+ return _this7.mapchange();
427
+ });
428
+ this.mapService.on('moveend', function () {
429
+ return _this7.mapchange();
430
+ });
213
431
  }
214
- (_a = this.tilesetManager) == null ? void 0 : _a.update(zoom, latLonBounds);
215
- }
216
- bindTilesetEvent() {
217
- if (!this.tilesetManager) {
218
- return;
432
+ }, {
433
+ key: "getCurrentView",
434
+ value: function getCurrentView() {
435
+ var bounds = this.mapService.getBounds();
436
+ var latLonBounds = [bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]];
437
+ var zoom = this.mapService.getZoom();
438
+ return {
439
+ latLonBounds: latLonBounds,
440
+ zoom: zoom
441
+ };
219
442
  }
220
- this.tilesetManager.on("tile-loaded", (tile) => {
221
- });
222
- this.tilesetManager.on("tile-unload", (tile) => {
223
- this.tileUnLoad(tile);
224
- });
225
- this.tilesetManager.on("tile-error", (error, tile) => {
226
- this.tileError(error);
227
- });
228
- this.tilesetManager.on("tile-update", () => {
229
- this.tileUpdate();
230
- });
231
- this.mapService.on("zoomend", () => this.mapchange());
232
- this.mapService.on("moveend", () => this.mapchange());
233
- }
234
- getCurrentView() {
235
- const bounds = this.mapService.getBounds();
236
- const latLonBounds = [
237
- bounds[0][0],
238
- bounds[0][1],
239
- bounds[1][0],
240
- bounds[1][1]
241
- ];
242
- const zoom = this.mapService.getZoom();
243
- return { latLonBounds, zoom };
244
- }
245
- };
246
- // Annotate the CommonJS export names for ESM import in node:
247
- 0 && (module.exports = {});
443
+ }]);
444
+ return BaseTileLayer;
445
+ }();
446
+
447
+ exports.default = BaseTileLayer;