@antv/l7-layers 2.9.25-alpha.0 → 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 (125) hide show
  1. package/es/heatmap/models/heatmap.js +1 -1
  2. package/es/tile/utils.js +1 -1
  3. package/lib/Geometry/index.js +114 -77
  4. package/lib/Geometry/models/billboard.js +232 -181
  5. package/lib/Geometry/models/index.js +18 -34
  6. package/lib/Geometry/models/plane.js +407 -278
  7. package/lib/Geometry/models/sprite.js +291 -189
  8. package/lib/canvas/index.js +101 -66
  9. package/lib/canvas/models/canvas.js +207 -140
  10. package/lib/canvas/models/index.js +12 -30
  11. package/lib/citybuliding/building.js +98 -63
  12. package/lib/citybuliding/models/build.js +192 -146
  13. package/lib/core/BaseLayer.js +1331 -814
  14. package/lib/core/BaseModel.js +457 -279
  15. package/lib/core/interface.js +40 -53
  16. package/lib/core/schema.js +21 -39
  17. package/lib/core/shape/Path.js +67 -79
  18. package/lib/core/shape/extrude.js +132 -91
  19. package/lib/core/triangulation.js +378 -196
  20. package/lib/earth/index.js +100 -62
  21. package/lib/earth/models/atmosphere.js +146 -112
  22. package/lib/earth/models/base.js +210 -150
  23. package/lib/earth/models/bloomsphere.js +146 -112
  24. package/lib/earth/utils.js +111 -91
  25. package/lib/heatmap/index.js +149 -92
  26. package/lib/heatmap/models/grid.js +118 -91
  27. package/lib/heatmap/models/grid3d.js +155 -123
  28. package/lib/heatmap/models/heatmap.js +475 -338
  29. package/lib/heatmap/models/hexagon.js +121 -92
  30. package/lib/heatmap/models/index.js +22 -37
  31. package/lib/heatmap/triangulation.js +31 -47
  32. package/lib/image/index.js +111 -74
  33. package/lib/image/models/dataImage.js +232 -174
  34. package/lib/image/models/image.js +175 -128
  35. package/lib/image/models/index.js +15 -32
  36. package/lib/index.js +263 -97
  37. package/lib/line/index.js +131 -85
  38. package/lib/line/models/arc.js +352 -237
  39. package/lib/line/models/arc_3d.js +334 -228
  40. package/lib/line/models/earthArc_3d.js +336 -228
  41. package/lib/line/models/great_circle.js +291 -200
  42. package/lib/line/models/half.js +286 -201
  43. package/lib/line/models/index.js +42 -50
  44. package/lib/line/models/line.js +428 -299
  45. package/lib/line/models/linearline.js +277 -203
  46. package/lib/line/models/simpleLine.js +239 -175
  47. package/lib/line/models/tile.js +348 -237
  48. package/lib/line/models/wall.js +327 -235
  49. package/lib/mask/index.js +92 -59
  50. package/lib/mask/models/fill.js +134 -82
  51. package/lib/mask/models/index.js +12 -30
  52. package/lib/plugins/DataMappingPlugin.js +342 -224
  53. package/lib/plugins/DataSourcePlugin.js +102 -87
  54. package/lib/plugins/FeatureScalePlugin.js +330 -240
  55. package/lib/plugins/LayerAnimateStylePlugin.js +61 -55
  56. package/lib/plugins/LayerModelPlugin.js +80 -73
  57. package/lib/plugins/LayerStylePlugin.js +48 -51
  58. package/lib/plugins/LightingPlugin.js +80 -68
  59. package/lib/plugins/MultiPassRendererPlugin.js +91 -65
  60. package/lib/plugins/PixelPickingPlugin.js +150 -109
  61. package/lib/plugins/RegisterStyleAttributePlugin.js +110 -110
  62. package/lib/plugins/ShaderUniformPlugin.js +118 -99
  63. package/lib/plugins/UpdateModelPlugin.js +40 -47
  64. package/lib/plugins/UpdateStyleAttributePlugin.js +93 -75
  65. package/lib/point/index.js +226 -150
  66. package/lib/point/models/earthExtrude.js +279 -201
  67. package/lib/point/models/earthFill.js +287 -202
  68. package/lib/point/models/extrude.js +299 -203
  69. package/lib/point/models/fill.js +406 -275
  70. package/lib/point/models/fillmage.js +365 -256
  71. package/lib/point/models/image.js +241 -168
  72. package/lib/point/models/index.js +46 -52
  73. package/lib/point/models/normal.js +183 -134
  74. package/lib/point/models/radar.js +304 -211
  75. package/lib/point/models/simplePoint.js +194 -142
  76. package/lib/point/models/text.js +608 -385
  77. package/lib/point/models/tile.js +314 -223
  78. package/lib/point/shape/extrude.js +56 -52
  79. package/lib/polygon/index.js +154 -102
  80. package/lib/polygon/models/extrude.js +311 -223
  81. package/lib/polygon/models/fill.js +215 -153
  82. package/lib/polygon/models/index.js +46 -52
  83. package/lib/polygon/models/ocean.js +244 -173
  84. package/lib/polygon/models/tile.js +144 -100
  85. package/lib/polygon/models/water.js +222 -153
  86. package/lib/raster/buffers/triangulation.js +27 -40
  87. package/lib/raster/index.js +115 -75
  88. package/lib/raster/models/index.js +16 -33
  89. package/lib/raster/models/raster.js +178 -135
  90. package/lib/raster/raster.js +187 -132
  91. package/lib/tile/interface.js +4 -16
  92. package/lib/tile/manager/tileConfigManager.js +125 -86
  93. package/lib/tile/manager/tileLayerManager.js +313 -229
  94. package/lib/tile/manager/tilePickerManager.js +192 -123
  95. package/lib/tile/models/tileModel.js +71 -52
  96. package/lib/tile/tileFactory/base.js +432 -309
  97. package/lib/tile/tileFactory/index.js +51 -49
  98. package/lib/tile/tileFactory/line.js +65 -50
  99. package/lib/tile/tileFactory/point.js +65 -50
  100. package/lib/tile/tileFactory/polygon.js +65 -50
  101. package/lib/tile/tileFactory/raster.js +66 -54
  102. package/lib/tile/tileFactory/rasterData.js +88 -76
  103. package/lib/tile/tileFactory/rasterDataLayer.js +97 -62
  104. package/lib/tile/tileFactory/vectorLayer.js +168 -109
  105. package/lib/tile/tileLayer/baseTileLayer.js +420 -221
  106. package/lib/tile/tmsTileLayer.js +110 -67
  107. package/lib/tile/utils.js +110 -92
  108. package/lib/utils/blend.js +59 -79
  109. package/lib/utils/collision-index.js +107 -64
  110. package/lib/utils/dataMappingStyle.js +105 -60
  111. package/lib/utils/extrude_polyline.js +600 -398
  112. package/lib/utils/grid-index.js +163 -111
  113. package/lib/utils/layerData.js +130 -99
  114. package/lib/utils/multiPassRender.js +49 -41
  115. package/lib/utils/polylineNormal.js +148 -96
  116. package/lib/utils/simpleLine.js +100 -85
  117. package/lib/utils/symbol-layout.js +219 -116
  118. package/lib/utils/updateShape.js +15 -41
  119. package/lib/wind/index.js +109 -71
  120. package/lib/wind/models/index.js +12 -30
  121. package/lib/wind/models/utils.js +144 -105
  122. package/lib/wind/models/wind.js +333 -224
  123. package/lib/wind/models/windRender.js +329 -218
  124. package/lib/wind/models/windShader.js +23 -181
  125. package/package.json +6 -6
@@ -1,248 +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
- transforms
35
- }) {
36
- this.type = "baseTile";
37
- this.initedTileset = false;
38
- 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", {
39
38
  select: null,
40
39
  active: null
41
- };
42
- var _a;
43
- const parentSource = parent.getSource();
44
- 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
+
45
48
  this.sourceLayer = sourceLayer;
46
49
  this.parent = parent;
47
50
  this.mapService = mapService;
48
51
  this.layerService = layerService;
49
- this.tileLayerManager = new import_tileLayerManager.TileLayerManager(parent, mapService, rendererService, pickingService, layerService, transforms);
52
+ this.tileLayerManager = new _tileLayerManager.TileLayerManager(parent, mapService, rendererService, pickingService, layerService, transforms);
50
53
  this.initTileSetManager();
51
54
  this.bindSubLayerEvent();
52
55
  this.bindSubLayerPick();
53
56
  this.scaleField = this.parent.getScaleOptions();
54
57
  }
55
- get children() {
56
- return this.tileLayerManager.children;
57
- }
58
- render() {
59
- if (this.tileLayerManager) {
60
- 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;
61
67
  }
62
- }
63
- clearPick(type) {
64
- if (type === "mousemove") {
65
- this.tileLayerManager.tilePickManager.clearPick();
68
+ }, {
69
+ key: "render",
70
+ value: function render() {
71
+ if (this.tileLayerManager) {
72
+ this.tileLayerManager.render();
73
+ }
66
74
  }
67
- }
68
- clearPickState() {
69
- this.children.filter((child) => child.inited && child.isVisible()).filter((child) => child.getCurrentSelectedId() !== null).map((child) => {
70
- this.selectFeature(child, new Uint8Array([0, 0, 0, 0]));
71
- child.setCurrentSelectedId(null);
72
- });
73
- }
74
- pickLayers(target) {
75
- return this.tileLayerManager.pickLayers(target);
76
- }
77
- tileLoaded(tile) {
78
- }
79
- tileError(error) {
80
- console.warn("error:", error);
81
- }
82
- tileUnLoad(tile) {
83
- this.tileLayerManager.removeChilds(tile.layerIDList, false);
84
- }
85
- tileUpdate() {
86
- if (!this.tilesetManager) {
87
- return;
88
- }
89
- this.tilesetManager.tiles.filter((tile) => tile.isLoaded).map((tile) => {
90
- if (tile.layerIDList.length === 0) {
91
- const { layers, layerIDList } = this.tileLayerManager.createTile(tile);
92
- tile.layerIDList = layerIDList;
93
- this.tileLayerManager.addChilds(layers);
94
- } else {
95
- if (!tile.isVisibleChange) {
96
- return;
97
- }
98
- const layers = this.tileLayerManager.getChilds(tile.layerIDList);
99
- 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();
100
80
  }
101
- });
102
- if (this.tilesetManager.isLoaded) {
103
- this.parent.emit("tiles-loaded", this.tilesetManager.currentTiles);
104
81
  }
105
- }
106
- setPickState(layers) {
107
- if (this.pickColors.select) {
108
- const selectedId = (0, import_l7_utils.decodePickingColor)(this.pickColors.select);
109
- layers.map((layer) => {
110
- this.selectFeature(layer, this.pickColors.select);
111
- 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);
112
99
  });
113
100
  }
114
- if (this.pickColors.active) {
115
- const selectedId = (0, import_l7_utils.decodePickingColor)(this.pickColors.active);
116
- layers.filter((layer) => layer.inited && layer.isVisible()).map((layer) => {
117
- layer.hooks.beforeHighlight.call(this.pickColors.active);
118
- 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
+ }
119
156
  });
157
+
158
+ if (this.tilesetManager.isLoaded) {
159
+ // 将事件抛出,图层上可以使用瓦片
160
+ this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
161
+ }
120
162
  }
121
- }
122
- bindSubLayerPick() {
123
- this.tileLayerManager.tilePickManager.on("pick", (e) => {
124
- const [r, g, b] = e.pickedColors;
125
- if (e.type === "click") {
126
- const restLayers = this.children.filter((child) => child.inited && child.isVisible() && child.isVector).filter((child) => child !== e.layer);
127
- this.setSelect(restLayers, [r, g, b]);
128
- } else {
129
- 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
+ });
130
175
  }
131
- });
132
- this.tileLayerManager.tilePickManager.on("unpick", () => {
133
- this.pickColors.active = null;
134
- });
135
- }
136
- setHighlight(pickedColors) {
137
- const pickId = (0, import_l7_utils.decodePickingColor)(pickedColors);
138
- this.pickColors.active = pickedColors;
139
- this.children.filter((child) => child.inited && child.isVisible() && child.isVector).filter((child) => child.getPickID() !== pickId).map((child) => {
140
- child.setPickID(pickId);
141
- child.hooks.beforeHighlight.call(pickedColors);
142
- });
143
- }
144
- setSelect(layers, pickedColors) {
145
- const selectedId = (0, import_l7_utils.decodePickingColor)(pickedColors);
146
- layers.map((layer) => {
147
- if (layer.getCurrentSelectedId() === null || selectedId !== layer.getCurrentSelectedId()) {
148
- this.selectFeature(layer, pickedColors);
149
- layer.setCurrentSelectedId(selectedId);
150
- this.pickColors.select = pickedColors;
151
- } else {
152
- this.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
153
- layer.setCurrentSelectedId(null);
154
- 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
+ });
155
186
  }
156
- });
157
- const renderList = this.layerService.getRenderList();
158
- renderList.filter((layer) => layer.inited && !layer.isVector && layer.isVisible() && layer.needPick("click")).filter((layer) => layer.getCurrentSelectedId() !== null).map((layer) => {
159
- this.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
160
- layer.setCurrentSelectedId(null);
161
- });
162
- }
163
- selectFeature(layer, pickedColors) {
164
- const [r, g, b] = pickedColors;
165
- layer.hooks.beforeSelect.call([r, g, b]);
166
- }
167
- bindSubLayerEvent() {
168
- this.parent.on("subLayerClick", (e) => {
169
- this.parent.emit("click", { ...e });
170
- });
171
- this.parent.on("subLayerMouseMove", (e) => this.parent.emit("mousemove", { ...e }));
172
- this.parent.on("subLayerMouseUp", (e) => this.parent.emit("mouseup", { ...e }));
173
- this.parent.on("subLayerMouseEnter", (e) => this.parent.emit("mouseenter", { ...e }));
174
- this.parent.on("subLayerMouseOut", (e) => this.parent.emit("mouseout", { ...e }));
175
- this.parent.on("subLayerMouseDown", (e) => this.parent.emit("mousedown", { ...e }));
176
- this.parent.on("subLayerContextmenu", (e) => this.parent.emit("contextmenu", { ...e }));
177
- this.parent.on("subLayerUnClick", (e) => this.parent.emit("unclick", { ...e }));
178
- this.parent.on("subLayerUnMouseMove", (e) => this.parent.emit("unmousemove", { ...e }));
179
- this.parent.on("subLayerUnMouseUp", (e) => this.parent.emit("unmouseup", { ...e }));
180
- this.parent.on("subLayerUnMouseDown", (e) => this.parent.emit("unmousedown", { ...e }));
181
- this.parent.on("subLayerUnContextmenu", (e) => this.parent.emit("uncontextmenu", { ...e }));
182
- }
183
- initTileSetManager() {
184
- var _a;
185
- const source = this.parent.getSource();
186
- this.tilesetManager = source.tileset;
187
- if (!this.initedTileset) {
188
- this.bindTilesetEvent();
189
- this.initedTileset = true;
190
- }
191
- const { latLonBounds, zoom } = this.getCurrentView();
192
- (_a = this.tilesetManager) == null ? void 0 : _a.update(zoom, latLonBounds);
193
- }
194
- mapchange() {
195
- var _a;
196
- const { latLonBounds, zoom } = this.getCurrentView();
197
- if (this.mapService.version === "GAODE1.x") {
198
- const { visible } = this.parent.getLayerConfig();
199
- if (zoom < 3 && visible) {
200
- this.parent.updateLayerConfig({ visible: false });
201
- this.layerService.updateLayerRenderList();
202
- } else if (zoom >= 3 && !visible) {
203
- this.parent.updateLayerConfig({ visible: true });
204
- 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;
205
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);
206
354
  }
207
- if (this.lastViewStates && this.lastViewStates.zoom === zoom && this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
208
- 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);
209
397
  }
210
- this.lastViewStates = { zoom, latLonBounds };
211
- if (this.timer) {
212
- clearTimeout(this.timer);
213
- 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
+ });
214
431
  }
215
- (_a = this.tilesetManager) == null ? void 0 : _a.update(zoom, latLonBounds);
216
- }
217
- bindTilesetEvent() {
218
- if (!this.tilesetManager) {
219
- 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
+ };
220
442
  }
221
- this.tilesetManager.on("tile-loaded", (tile) => {
222
- });
223
- this.tilesetManager.on("tile-unload", (tile) => {
224
- this.tileUnLoad(tile);
225
- });
226
- this.tilesetManager.on("tile-error", (error, tile) => {
227
- this.tileError(error);
228
- });
229
- this.tilesetManager.on("tile-update", () => {
230
- this.tileUpdate();
231
- });
232
- this.mapService.on("zoomend", () => this.mapchange());
233
- this.mapService.on("moveend", () => this.mapchange());
234
- }
235
- getCurrentView() {
236
- const bounds = this.mapService.getBounds();
237
- const latLonBounds = [
238
- bounds[0][0],
239
- bounds[0][1],
240
- bounds[1][0],
241
- bounds[1][1]
242
- ];
243
- const zoom = this.mapService.getZoom();
244
- return { latLonBounds, zoom };
245
- }
246
- };
247
- // Annotate the CommonJS export names for ESM import in node:
248
- 0 && (module.exports = {});
443
+ }]);
444
+ return BaseTileLayer;
445
+ }();
446
+
447
+ exports.default = BaseTileLayer;