@antv/l7-layers 2.8.45 → 2.9.0
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.
- package/es/core/BaseLayer.d.ts +3 -1
- package/es/core/BaseLayer.js +23 -3
- package/es/core/BaseLayer.js.map +1 -1
- package/es/core/BaseModel.d.ts +2 -1
- package/es/core/BaseModel.js +3 -0
- package/es/core/BaseModel.js.map +1 -1
- package/es/core/interface.d.ts +12 -0
- package/es/core/interface.js.map +1 -1
- package/es/image/models/image.js.map +1 -1
- package/es/line/index.d.ts +1 -1
- package/es/line/index.js +7 -1
- package/es/line/index.js.map +1 -1
- package/es/line/models/index.d.ts +1 -1
- package/es/line/models/index.js +5 -1
- package/es/line/models/index.js.map +1 -1
- package/es/line/models/tile.d.ts +20 -0
- package/es/line/models/tile.js +327 -0
- package/es/line/models/tile.js.map +1 -0
- package/es/plugins/ShaderUniformPlugin.js +3 -1
- package/es/plugins/ShaderUniformPlugin.js.map +1 -1
- package/es/point/index.d.ts +1 -1
- package/es/point/index.js +8 -2
- package/es/point/index.js.map +1 -1
- package/es/point/models/index.d.ts +1 -1
- package/es/point/models/index.js +5 -1
- package/es/point/models/index.js.map +1 -1
- package/es/point/models/tile.d.ts +31 -0
- package/es/point/models/tile.js +291 -0
- package/es/point/models/tile.js.map +1 -0
- package/es/polygon/index.js +6 -0
- package/es/polygon/index.js.map +1 -1
- package/es/polygon/models/index.d.ts +1 -1
- package/es/polygon/models/index.js +5 -1
- package/es/polygon/models/index.js.map +1 -1
- package/es/polygon/models/tile.d.ts +16 -0
- package/es/polygon/models/tile.js +137 -0
- package/es/polygon/models/tile.js.map +1 -0
- package/es/raster/index.d.ts +2 -2
- package/es/raster/index.js +4 -4
- package/es/raster/index.js.map +1 -1
- package/es/raster/models/index.js +1 -1
- package/es/raster/models/index.js.map +1 -1
- package/es/raster/models/raster.d.ts +1 -0
- package/es/raster/models/raster.js +8 -2
- package/es/raster/models/raster.js.map +1 -1
- package/es/tile/interface.d.ts +28 -0
- package/es/tile/interface.js +2 -0
- package/es/tile/interface.js.map +1 -0
- package/es/tile/manager/tileConfigManager.d.ts +17 -0
- package/es/tile/manager/tileConfigManager.js +123 -0
- package/es/tile/manager/tileConfigManager.js.map +1 -0
- package/es/tile/manager/tileLayerManager.d.ts +34 -0
- package/es/tile/manager/tileLayerManager.js +283 -0
- package/es/tile/manager/tileLayerManager.js.map +1 -0
- package/es/tile/manager/tilePickerManager.d.ts +20 -0
- package/es/tile/manager/tilePickerManager.js +164 -0
- package/es/tile/manager/tilePickerManager.js.map +1 -0
- package/es/tile/models/tileModel.d.ts +8 -0
- package/es/tile/models/tileModel.js +61 -0
- package/es/tile/models/tileModel.js.map +1 -0
- package/es/tile/tileFactory/base.d.ts +40 -0
- package/es/tile/tileFactory/base.js +352 -0
- package/es/tile/tileFactory/base.js.map +1 -0
- package/es/tile/tileFactory/index.d.ts +5 -0
- package/es/tile/tileFactory/index.js +30 -0
- package/es/tile/tileFactory/index.js.map +1 -0
- package/es/tile/tileFactory/line.d.ts +12 -0
- package/es/tile/tileFactory/line.js +65 -0
- package/es/tile/tileFactory/line.js.map +1 -0
- package/es/tile/tileFactory/point.d.ts +12 -0
- package/es/tile/tileFactory/point.js +65 -0
- package/es/tile/tileFactory/point.js.map +1 -0
- package/es/tile/tileFactory/polygon.d.ts +12 -0
- package/es/tile/tileFactory/polygon.js +65 -0
- package/es/tile/tileFactory/polygon.js.map +1 -0
- package/es/tile/tileFactory/raster.d.ts +12 -0
- package/es/tile/tileFactory/raster.js +61 -0
- package/es/tile/tileFactory/raster.js.map +1 -0
- package/es/tile/tileFactory/rasterData.d.ts +12 -0
- package/es/tile/tileFactory/rasterData.js +75 -0
- package/es/tile/tileFactory/rasterData.js.map +1 -0
- package/es/tile/tileFactory/rasterDataLayer.d.ts +19 -0
- package/es/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +39 -32
- package/es/tile/tileFactory/rasterDataLayer.js.map +1 -0
- package/es/tile/tileFactory/vectorLayer.d.ts +27 -0
- package/es/tile/tileFactory/vectorLayer.js +131 -0
- package/es/tile/tileFactory/vectorLayer.js.map +1 -0
- package/es/tile/tileLayer/baseTileLayer.d.ts +51 -0
- package/es/tile/tileLayer/baseTileLayer.js +409 -0
- package/es/tile/tileLayer/baseTileLayer.js.map +1 -0
- package/es/tile/tmsTileLayer.d.ts +7 -0
- package/es/tile/tmsTileLayer.js +94 -0
- package/es/tile/tmsTileLayer.js.map +1 -0
- package/es/tile/utils.d.ts +11 -0
- package/es/tile/utils.js +120 -0
- package/es/tile/utils.js.map +1 -0
- package/lib/core/BaseLayer.js +21 -2
- package/lib/core/BaseLayer.js.map +1 -1
- package/lib/core/BaseModel.js +2 -0
- package/lib/core/BaseModel.js.map +1 -1
- package/lib/core/interface.js.map +1 -1
- package/lib/image/models/image.js.map +1 -1
- package/lib/line/index.js +7 -1
- package/lib/line/index.js.map +1 -1
- package/lib/line/models/index.js +7 -1
- package/lib/line/models/index.js.map +1 -1
- package/lib/line/models/tile.js +342 -0
- package/lib/line/models/tile.js.map +1 -0
- package/lib/plugins/ShaderUniformPlugin.js +3 -1
- package/lib/plugins/ShaderUniformPlugin.js.map +1 -1
- package/lib/point/index.js +8 -2
- package/lib/point/index.js.map +1 -1
- package/lib/point/models/index.js +7 -1
- package/lib/point/models/index.js.map +1 -1
- package/lib/point/models/tile.js +308 -0
- package/lib/point/models/tile.js.map +1 -0
- package/lib/polygon/index.js +6 -0
- package/lib/polygon/index.js.map +1 -1
- package/lib/polygon/models/index.js +7 -1
- package/lib/polygon/models/index.js.map +1 -1
- package/lib/polygon/models/tile.js +152 -0
- package/lib/polygon/models/tile.js.map +1 -0
- package/lib/raster/index.js +4 -4
- package/lib/raster/index.js.map +1 -1
- package/lib/raster/models/index.js +2 -2
- package/lib/raster/models/index.js.map +1 -1
- package/lib/raster/models/raster.js +8 -2
- package/lib/raster/models/raster.js.map +1 -1
- package/lib/tile/interface.js +2 -0
- package/lib/tile/interface.js.map +1 -0
- package/lib/tile/manager/tileConfigManager.js +134 -0
- package/lib/tile/manager/tileConfigManager.js.map +1 -0
- package/lib/tile/manager/tileLayerManager.js +291 -0
- package/lib/tile/manager/tileLayerManager.js.map +1 -0
- package/lib/tile/manager/tilePickerManager.js +170 -0
- package/lib/tile/manager/tilePickerManager.js.map +1 -0
- package/lib/tile/models/tileModel.js +73 -0
- package/lib/tile/models/tileModel.js.map +1 -0
- package/lib/tile/tileFactory/base.js +366 -0
- package/lib/tile/tileFactory/base.js.map +1 -0
- package/lib/tile/tileFactory/index.js +60 -0
- package/lib/tile/tileFactory/index.js.map +1 -0
- package/lib/tile/tileFactory/line.js +76 -0
- package/lib/tile/tileFactory/line.js.map +1 -0
- package/lib/tile/tileFactory/point.js +76 -0
- package/lib/tile/tileFactory/point.js.map +1 -0
- package/lib/tile/tileFactory/polygon.js +76 -0
- package/lib/tile/tileFactory/polygon.js.map +1 -0
- package/lib/tile/tileFactory/raster.js +74 -0
- package/lib/tile/tileFactory/raster.js.map +1 -0
- package/lib/tile/tileFactory/rasterData.js +88 -0
- package/lib/tile/tileFactory/rasterData.js.map +1 -0
- package/lib/{core/LayerGroup.js → tile/tileFactory/rasterDataLayer.js} +40 -32
- package/lib/tile/tileFactory/rasterDataLayer.js.map +1 -0
- package/lib/tile/tileFactory/vectorLayer.js +145 -0
- package/lib/tile/tileFactory/vectorLayer.js.map +1 -0
- package/lib/tile/tileLayer/baseTileLayer.js +408 -0
- package/lib/tile/tileLayer/baseTileLayer.js.map +1 -0
- package/lib/tile/tmsTileLayer.js +109 -0
- package/lib/tile/tmsTileLayer.js.map +1 -0
- package/lib/tile/utils.js +142 -0
- package/lib/tile/utils.js.map +1 -0
- package/package.json +7 -5
- package/es/core/LayerGroup.d.ts +0 -9
- package/es/core/LayerGroup.js.map +0 -1
- package/es/raster/models/raste-tile.d.ts +0 -23
- package/es/raster/models/raste-tile.js +0 -285
- package/es/raster/models/raste-tile.js.map +0 -1
- package/lib/core/LayerGroup.js.map +0 -1
- package/lib/raster/models/raste-tile.js +0 -294
- package/lib/raster/models/raste-tile.js.map +0 -1
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
|
|
6
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
7
|
+
|
|
8
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
9
|
+
|
|
10
|
+
import { decodePickingColor } from '@antv/l7-utils';
|
|
11
|
+
import { TileLayerManager } from '../manager/tileLayerManager';
|
|
12
|
+
|
|
13
|
+
var BaseTileLayer = function () {
|
|
14
|
+
function BaseTileLayer(_ref) {
|
|
15
|
+
var _parentSource$data;
|
|
16
|
+
|
|
17
|
+
var parent = _ref.parent,
|
|
18
|
+
rendererService = _ref.rendererService,
|
|
19
|
+
mapService = _ref.mapService,
|
|
20
|
+
layerService = _ref.layerService,
|
|
21
|
+
pickingService = _ref.pickingService;
|
|
22
|
+
|
|
23
|
+
_classCallCheck(this, BaseTileLayer);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "type", 'baseTile');
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "sourceLayer", void 0);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "parent", void 0);
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "initedTileset", false);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "tilesetManager", void 0);
|
|
34
|
+
|
|
35
|
+
_defineProperty(this, "tileLayerManager", void 0);
|
|
36
|
+
|
|
37
|
+
_defineProperty(this, "lastViewStates", void 0);
|
|
38
|
+
|
|
39
|
+
_defineProperty(this, "timer", void 0);
|
|
40
|
+
|
|
41
|
+
_defineProperty(this, "mapService", void 0);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "layerService", void 0);
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "pickColors", {
|
|
46
|
+
select: null,
|
|
47
|
+
active: null
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
var parentSource = parent.getSource();
|
|
51
|
+
|
|
52
|
+
var _ref2 = (parentSource === null || parentSource === void 0 ? void 0 : (_parentSource$data = parentSource.data) === null || _parentSource$data === void 0 ? void 0 : _parentSource$data.tilesetOptions) || {},
|
|
53
|
+
sourceLayer = _ref2.sourceLayer,
|
|
54
|
+
coords = _ref2.coords,
|
|
55
|
+
featureId = _ref2.featureId;
|
|
56
|
+
|
|
57
|
+
this.sourceLayer = sourceLayer;
|
|
58
|
+
this.parent = parent;
|
|
59
|
+
this.mapService = mapService;
|
|
60
|
+
this.layerService = layerService;
|
|
61
|
+
this.tileLayerManager = new TileLayerManager(parent, mapService, rendererService, pickingService, layerService);
|
|
62
|
+
this.initTileSetManager();
|
|
63
|
+
this.bindSubLayerEvent();
|
|
64
|
+
this.bindSubLayerPick();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
_createClass(BaseTileLayer, [{
|
|
68
|
+
key: "children",
|
|
69
|
+
get: function get() {
|
|
70
|
+
return this.tileLayerManager.children;
|
|
71
|
+
}
|
|
72
|
+
}, {
|
|
73
|
+
key: "scale",
|
|
74
|
+
value: function scale(field, cfg) {
|
|
75
|
+
this.children.map(function (child) {
|
|
76
|
+
child.scale(field, cfg);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}, {
|
|
80
|
+
key: "render",
|
|
81
|
+
value: function render() {
|
|
82
|
+
if (this.tileLayerManager) {
|
|
83
|
+
this.tileLayerManager.render();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
key: "clearPick",
|
|
88
|
+
value: function clearPick(type) {
|
|
89
|
+
if (type === 'mousemove') {
|
|
90
|
+
this.tileLayerManager.tilePickManager.clearPick();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "clearPickState",
|
|
95
|
+
value: function clearPickState() {
|
|
96
|
+
var _this = this;
|
|
97
|
+
|
|
98
|
+
this.children.filter(function (child) {
|
|
99
|
+
return child.inited && child.isVisible();
|
|
100
|
+
}).filter(function (child) {
|
|
101
|
+
return child.getCurrentSelectedId() !== null;
|
|
102
|
+
}).map(function (child) {
|
|
103
|
+
_this.selectFeature(child, new Uint8Array([0, 0, 0, 0]));
|
|
104
|
+
|
|
105
|
+
child.setCurrentSelectedId(null);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
key: "pickLayers",
|
|
110
|
+
value: function pickLayers(target) {
|
|
111
|
+
return this.tileLayerManager.pickLayers(target);
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "tileLoaded",
|
|
115
|
+
value: function tileLoaded(tile) {}
|
|
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);
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "tileUpdate",
|
|
128
|
+
value: function tileUpdate() {
|
|
129
|
+
var _this2 = this;
|
|
130
|
+
|
|
131
|
+
if (!this.tilesetManager) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this.tilesetManager.tiles.filter(function (tile) {
|
|
136
|
+
return tile.isLoaded;
|
|
137
|
+
}).map(function (tile) {
|
|
138
|
+
if (tile.layerIDList.length === 0) {
|
|
139
|
+
var _this2$tileLayerManag = _this2.tileLayerManager.createTile(tile),
|
|
140
|
+
layers = _this2$tileLayerManag.layers,
|
|
141
|
+
layerIDList = _this2$tileLayerManag.layerIDList;
|
|
142
|
+
|
|
143
|
+
tile.layerIDList = layerIDList;
|
|
144
|
+
|
|
145
|
+
_this2.tileLayerManager.addChilds(layers);
|
|
146
|
+
} else {
|
|
147
|
+
if (!tile.isVisibleChanged) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
var _layers = _this2.tileLayerManager.getChilds(tile.layerIDList);
|
|
152
|
+
|
|
153
|
+
_this2.tileLayerManager.updateLayersConfig(_layers, 'visible', tile.isVisible);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (this.tilesetManager.isLoaded) {
|
|
158
|
+
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "setPickState",
|
|
163
|
+
value: function setPickState(layers) {
|
|
164
|
+
var _this3 = this;
|
|
165
|
+
|
|
166
|
+
if (this.pickColors.select) {
|
|
167
|
+
var selectedId = decodePickingColor(this.pickColors.select);
|
|
168
|
+
layers.map(function (layer) {
|
|
169
|
+
_this3.selectFeature(layer, _this3.pickColors.select);
|
|
170
|
+
|
|
171
|
+
layer.setCurrentSelectedId(selectedId);
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.pickColors.active) {
|
|
176
|
+
var _selectedId = decodePickingColor(this.pickColors.active);
|
|
177
|
+
|
|
178
|
+
layers.filter(function (layer) {
|
|
179
|
+
return layer.inited && layer.isVisible();
|
|
180
|
+
}).map(function (layer) {
|
|
181
|
+
layer.hooks.beforeHighlight.call(_this3.pickColors.active);
|
|
182
|
+
layer.setCurrentPickId(_selectedId);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
key: "bindSubLayerPick",
|
|
188
|
+
value: function bindSubLayerPick() {
|
|
189
|
+
var _this4 = this;
|
|
190
|
+
|
|
191
|
+
this.tileLayerManager.tilePickManager.on('pick', function (e) {
|
|
192
|
+
var _e$pickedColors = _slicedToArray(e.pickedColors, 3),
|
|
193
|
+
r = _e$pickedColors[0],
|
|
194
|
+
g = _e$pickedColors[1],
|
|
195
|
+
b = _e$pickedColors[2];
|
|
196
|
+
|
|
197
|
+
if (e.type === 'click') {
|
|
198
|
+
var restLayers = _this4.children.filter(function (child) {
|
|
199
|
+
return child.inited && child.isVisible() && child.isVector;
|
|
200
|
+
}).filter(function (child) {
|
|
201
|
+
return child !== e.layer;
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
_this4.setSelect(restLayers, [r, g, b]);
|
|
205
|
+
} else {
|
|
206
|
+
_this4.setHighlight([r, g, b]);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
this.tileLayerManager.tilePickManager.on('unpick', function () {
|
|
210
|
+
_this4.pickColors.active = null;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}, {
|
|
214
|
+
key: "setHighlight",
|
|
215
|
+
value: function setHighlight(pickedColors) {
|
|
216
|
+
var pickId = decodePickingColor(pickedColors);
|
|
217
|
+
this.pickColors.active = pickedColors;
|
|
218
|
+
this.children.filter(function (child) {
|
|
219
|
+
return child.inited && child.isVisible() && child.isVector;
|
|
220
|
+
}).filter(function (child) {
|
|
221
|
+
return child.getPickID() !== pickId;
|
|
222
|
+
}).map(function (child) {
|
|
223
|
+
child.setPickID(pickId);
|
|
224
|
+
child.hooks.beforeHighlight.call(pickedColors);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}, {
|
|
228
|
+
key: "setSelect",
|
|
229
|
+
value: function setSelect(layers, pickedColors) {
|
|
230
|
+
var _this5 = this;
|
|
231
|
+
|
|
232
|
+
var selectedId = decodePickingColor(pickedColors);
|
|
233
|
+
layers.map(function (layer) {
|
|
234
|
+
if (layer.getCurrentSelectedId() === null || selectedId !== layer.getCurrentSelectedId()) {
|
|
235
|
+
_this5.selectFeature(layer, pickedColors);
|
|
236
|
+
|
|
237
|
+
layer.setCurrentSelectedId(selectedId);
|
|
238
|
+
_this5.pickColors.select = pickedColors;
|
|
239
|
+
} else {
|
|
240
|
+
_this5.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
|
|
241
|
+
|
|
242
|
+
layer.setCurrentSelectedId(null);
|
|
243
|
+
_this5.pickColors.select = null;
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
var renderList = this.layerService.getRenderList();
|
|
247
|
+
renderList.filter(function (layer) {
|
|
248
|
+
return layer.inited && !layer.isVector && layer.isVisible() && layer.needPick('click');
|
|
249
|
+
}).filter(function (layer) {
|
|
250
|
+
return layer.getCurrentSelectedId() !== null;
|
|
251
|
+
}).map(function (layer) {
|
|
252
|
+
_this5.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));
|
|
253
|
+
|
|
254
|
+
layer.setCurrentSelectedId(null);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "selectFeature",
|
|
259
|
+
value: function selectFeature(layer, pickedColors) {
|
|
260
|
+
var _pickedColors = _slicedToArray(pickedColors, 3),
|
|
261
|
+
r = _pickedColors[0],
|
|
262
|
+
g = _pickedColors[1],
|
|
263
|
+
b = _pickedColors[2];
|
|
264
|
+
|
|
265
|
+
layer.hooks.beforeSelect.call([r, g, b]);
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
268
|
+
key: "bindSubLayerEvent",
|
|
269
|
+
value: function bindSubLayerEvent() {
|
|
270
|
+
var _this6 = this;
|
|
271
|
+
|
|
272
|
+
this.parent.on('subLayerClick', function (e) {
|
|
273
|
+
_this6.parent.emit('click', _objectSpread({}, e));
|
|
274
|
+
});
|
|
275
|
+
this.parent.on('subLayerMouseMove', function (e) {
|
|
276
|
+
return _this6.parent.emit('mousemove', _objectSpread({}, e));
|
|
277
|
+
});
|
|
278
|
+
this.parent.on('subLayerMouseUp', function (e) {
|
|
279
|
+
return _this6.parent.emit('mouseup', _objectSpread({}, e));
|
|
280
|
+
});
|
|
281
|
+
this.parent.on('subLayerMouseEnter', function (e) {
|
|
282
|
+
return _this6.parent.emit('mouseenter', _objectSpread({}, e));
|
|
283
|
+
});
|
|
284
|
+
this.parent.on('subLayerMouseOut', function (e) {
|
|
285
|
+
return _this6.parent.emit('mouseout', _objectSpread({}, e));
|
|
286
|
+
});
|
|
287
|
+
this.parent.on('subLayerMouseDown', function (e) {
|
|
288
|
+
return _this6.parent.emit('mousedown', _objectSpread({}, e));
|
|
289
|
+
});
|
|
290
|
+
this.parent.on('subLayerContextmenu', function (e) {
|
|
291
|
+
return _this6.parent.emit('contextmenu', _objectSpread({}, e));
|
|
292
|
+
});
|
|
293
|
+
this.parent.on('subLayerUnClick', function (e) {
|
|
294
|
+
return _this6.parent.emit('unclick', _objectSpread({}, e));
|
|
295
|
+
});
|
|
296
|
+
this.parent.on('subLayerUnMouseMove', function (e) {
|
|
297
|
+
return _this6.parent.emit('unmousemove', _objectSpread({}, e));
|
|
298
|
+
});
|
|
299
|
+
this.parent.on('subLayerUnMouseUp', function (e) {
|
|
300
|
+
return _this6.parent.emit('unmouseup', _objectSpread({}, e));
|
|
301
|
+
});
|
|
302
|
+
this.parent.on('subLayerUnMouseDown', function (e) {
|
|
303
|
+
return _this6.parent.emit('unmousedown', _objectSpread({}, e));
|
|
304
|
+
});
|
|
305
|
+
this.parent.on('subLayerUnContextmenu', function (e) {
|
|
306
|
+
return _this6.parent.emit('uncontextmenu', _objectSpread({}, e));
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}, {
|
|
310
|
+
key: "initTileSetManager",
|
|
311
|
+
value: function initTileSetManager() {
|
|
312
|
+
var _this$tilesetManager;
|
|
313
|
+
|
|
314
|
+
var source = this.parent.getSource();
|
|
315
|
+
this.tilesetManager = source.tileset;
|
|
316
|
+
|
|
317
|
+
if (!this.initedTileset) {
|
|
318
|
+
this.bindTilesetEvent();
|
|
319
|
+
this.initedTileset = true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
var _this$getCurrentView = this.getCurrentView(),
|
|
323
|
+
latLonBounds = _this$getCurrentView.latLonBounds,
|
|
324
|
+
zoom = _this$getCurrentView.zoom;
|
|
325
|
+
|
|
326
|
+
(_this$tilesetManager = this.tilesetManager) === null || _this$tilesetManager === void 0 ? void 0 : _this$tilesetManager.update(zoom, latLonBounds);
|
|
327
|
+
}
|
|
328
|
+
}, {
|
|
329
|
+
key: "bindTilesetEvent",
|
|
330
|
+
value: function bindTilesetEvent() {
|
|
331
|
+
var _this7 = this;
|
|
332
|
+
|
|
333
|
+
if (!this.tilesetManager) {
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
this.tilesetManager.on('tile-loaded', function (tile) {});
|
|
338
|
+
this.tilesetManager.on('tile-unload', function (tile) {
|
|
339
|
+
_this7.tileUnLoad(tile);
|
|
340
|
+
});
|
|
341
|
+
this.tilesetManager.on('tile-error', function (error, tile) {
|
|
342
|
+
_this7.tileError(error);
|
|
343
|
+
});
|
|
344
|
+
this.tilesetManager.on('tile-update', function () {
|
|
345
|
+
_this7.tileUpdate();
|
|
346
|
+
});
|
|
347
|
+
this.mapService.on('mapchange', function (e) {
|
|
348
|
+
var _this7$getCurrentView = _this7.getCurrentView(),
|
|
349
|
+
latLonBounds = _this7$getCurrentView.latLonBounds,
|
|
350
|
+
zoom = _this7$getCurrentView.zoom;
|
|
351
|
+
|
|
352
|
+
if (_this7.mapService.version === 'GAODE1.x') {
|
|
353
|
+
var _this7$parent$getLaye = _this7.parent.getLayerConfig(),
|
|
354
|
+
visible = _this7$parent$getLaye.visible;
|
|
355
|
+
|
|
356
|
+
if (zoom < 3 && visible) {
|
|
357
|
+
_this7.parent.updateLayerConfig({
|
|
358
|
+
visible: false
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
_this7.layerService.updateLayerRenderList();
|
|
362
|
+
} else if (zoom >= 3 && !visible) {
|
|
363
|
+
_this7.parent.updateLayerConfig({
|
|
364
|
+
visible: true
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
_this7.layerService.updateLayerRenderList();
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if (_this7.lastViewStates && _this7.lastViewStates.zoom === zoom && _this7.lastViewStates.latLonBounds.toString() === latLonBounds.toString()) {
|
|
372
|
+
return;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
_this7.lastViewStates = {
|
|
376
|
+
zoom: zoom,
|
|
377
|
+
latLonBounds: latLonBounds
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
if (_this7.timer) {
|
|
381
|
+
clearTimeout(_this7.timer);
|
|
382
|
+
_this7.timer = null;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
_this7.timer = setTimeout(function () {
|
|
386
|
+
var _this7$tilesetManager;
|
|
387
|
+
|
|
388
|
+
(_this7$tilesetManager = _this7.tilesetManager) === null || _this7$tilesetManager === void 0 ? void 0 : _this7$tilesetManager.update(zoom, latLonBounds);
|
|
389
|
+
}, 250);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "getCurrentView",
|
|
394
|
+
value: function getCurrentView() {
|
|
395
|
+
var bounds = this.mapService.getBounds();
|
|
396
|
+
var latLonBounds = [bounds[0][0], bounds[0][1], bounds[1][0], bounds[1][1]];
|
|
397
|
+
var zoom = this.mapService.getZoom();
|
|
398
|
+
return {
|
|
399
|
+
latLonBounds: latLonBounds,
|
|
400
|
+
zoom: zoom
|
|
401
|
+
};
|
|
402
|
+
}
|
|
403
|
+
}]);
|
|
404
|
+
|
|
405
|
+
return BaseTileLayer;
|
|
406
|
+
}();
|
|
407
|
+
|
|
408
|
+
export { BaseTileLayer as default };
|
|
409
|
+
//# sourceMappingURL=baseTileLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/tile/tileLayer/baseTileLayer.ts"],"names":["decodePickingColor","TileLayerManager","BaseTileLayer","parent","rendererService","mapService","layerService","pickingService","select","active","parentSource","getSource","data","tilesetOptions","sourceLayer","coords","featureId","tileLayerManager","initTileSetManager","bindSubLayerEvent","bindSubLayerPick","children","field","cfg","map","child","scale","render","type","tilePickManager","clearPick","filter","inited","isVisible","getCurrentSelectedId","selectFeature","Uint8Array","setCurrentSelectedId","target","pickLayers","tile","error","console","warn","removeChilds","layerIDList","tilesetManager","tiles","isLoaded","length","createTile","layers","addChilds","isVisibleChanged","getChilds","updateLayersConfig","emit","currentTiles","pickColors","selectedId","layer","hooks","beforeHighlight","call","setCurrentPickId","on","e","pickedColors","r","g","b","restLayers","isVector","setSelect","setHighlight","pickId","getPickID","setPickID","renderList","getRenderList","needPick","beforeSelect","source","tileset","initedTileset","bindTilesetEvent","getCurrentView","latLonBounds","zoom","update","tileUnLoad","tileError","tileUpdate","version","getLayerConfig","visible","updateLayerConfig","updateLayerRenderList","lastViewStates","toString","timer","clearTimeout","setTimeout","bounds","getBounds","getZoom"],"mappings":";;;;;;;;;AAYA,SAASA,kBAAT,QAAyD,gBAAzD;AACA,SAASC,gBAAT,QAAiC,6BAAjC;;IAEqBC,a;AA6BnB,+BAMsB;AAAA;;AAAA,QALpBC,MAKoB,QALpBA,MAKoB;AAAA,QAJpBC,eAIoB,QAJpBA,eAIoB;AAAA,QAHpBC,UAGoB,QAHpBA,UAGoB;AAAA,QAFpBC,YAEoB,QAFpBA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AY,EAAZA;AAAR,SAAtB;;AAEA,YAAI,MAAI,CAACa,KAAT,EAAgB;AACdC,UAAAA,YAAY,CAAC,MAAI,CAACD,KAAN,CAAZ;AACA,UAAA,MAAI,CAACA,KAAL,GAAa,IAAb;AACD;;AAED,QAAA,MAAI,CAACA,KAAL,GAAaE,UAAU,CAAC,YAAM;AAAA;;AAC5B,mCAAA,MAAI,CAACxD,cAAL,gFAAqB2C,MAArB,CAA4BD,IAA5B,EAAkCD,YAAlC;AACD,SAFsB,EAEpB,GAFoB,CAAvB;AAGD,OA/BD;AAgCD;;;WAED,0BAAyB;AACvB,UAAMgB,MAAM,GAAG,KAAKlG,UAAL,CAAgBmG,SAAhB,EAAf;AACA,UAAMjB,YAA8C,GAAG,CACrDgB,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CADqD,EAErDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAFqD,EAGrDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAHqD,EAIrDA,MAAM,CAAC,CAAD,CAAN,CAAU,CAAV,CAJqD,CAAvD;AAMA,UAAMf,IAAI,GAAG,KAAKnF,UAAL,CAAgBoG,OAAhB,EAAb;AAEA,aAAO;AAAElB,QAAAA,YAAY,EAAZA,YAAF;AAAgBC,QAAAA,IAAI,EAAJA;AAAhB,OAAP;AACD;;;;;;SAtYkBtF,a","sourcesContent":["import {\n IInteractionTarget,\n ILayer,\n ILayerService,\n IMapService,\n IScale,\n IScaleOptions,\n ISource,\n ITileLayer,\n ITileLayerManager,\n ITileLayerOPtions,\n} from '@antv/l7-core';\nimport { decodePickingColor, Tile, TilesetManager } from '@antv/l7-utils';\nimport { TileLayerManager } from '../manager/tileLayerManager';\n\nexport default class BaseTileLayer implements ITileLayer {\n public get children() {\n return this.tileLayerManager.children;\n }\n public type: string = 'baseTile';\n public sourceLayer: string;\n public parent: ILayer;\n // 瓦片是否加载成功\n public initedTileset: boolean = false;\n // 瓦片数据管理器\n public tilesetManager: TilesetManager | undefined;\n public tileLayerManager: ITileLayerManager;\n\n private lastViewStates: {\n zoom: number;\n latLonBounds: [number, number, number, number];\n };\n\n private timer: any;\n private mapService: IMapService;\n private layerService: ILayerService;\n private pickColors: {\n select: any;\n active: any;\n } = {\n select: null,\n active: null,\n };\n\n constructor({\n parent,\n rendererService,\n mapService,\n layerService,\n pickingService,\n }: ITileLayerOPtions) {\n const parentSource = parent.getSource();\n const { sourceLayer, coords, featureId } =\n parentSource?.data?.tilesetOptions || {};\n this.sourceLayer = sourceLayer;\n this.parent = parent;\n this.mapService = mapService;\n this.layerService = layerService;\n\n this.tileLayerManager = new TileLayerManager(\n parent,\n mapService,\n rendererService,\n pickingService,\n layerService,\n );\n\n this.initTileSetManager();\n this.bindSubLayerEvent();\n this.bindSubLayerPick();\n }\n\n /**\n * 直接透传 scale 方法\n * @param field\n * @param cfg\n */\n public scale(field: string | number | IScaleOptions, cfg?: IScale) {\n this.children.map((child) => {\n child.scale(field, cfg);\n });\n }\n\n /**\n * 渲染瓦片的图层\n */\n public render() {\n if (this.tileLayerManager) {\n this.tileLayerManager.render();\n }\n }\n\n public clearPick(type: string) {\n if (type === 'mousemove') {\n this.tileLayerManager.tilePickManager.clearPick();\n }\n }\n\n /**\n * 清除 select 的选中状态\n */\n public clearPickState() {\n this.children\n .filter((child) => child.inited && child.isVisible())\n .filter((child) => child.getCurrentSelectedId() !== null)\n .map((child) => {\n this.selectFeature(child, new Uint8Array([0, 0, 0, 0]));\n child.setCurrentSelectedId(null);\n });\n }\n\n /**\n * 瓦片图层独立的拾取逻辑\n * @param target\n * @returns\n */\n public pickLayers(target: IInteractionTarget) {\n return this.tileLayerManager.pickLayers(target);\n }\n\n public tileLoaded(tile: Tile) {\n //\n }\n\n public tileError(error: Error) {\n console.warn('error:', error);\n }\n\n public tileUnLoad(tile: Tile) {\n this.tileLayerManager.removeChilds(tile.layerIDList);\n }\n\n public tileUpdate() {\n // Base Function\n if (!this.tilesetManager) {\n return;\n }\n\n this.tilesetManager.tiles\n .filter((tile) => tile.isLoaded)\n .map((tile) => {\n if (tile.layerIDList.length === 0) {\n const { layers, layerIDList } = this.tileLayerManager.createTile(\n tile,\n );\n tile.layerIDList = layerIDList;\n this.tileLayerManager.addChilds(layers);\n } else {\n if (!tile.isVisibleChanged) {\n return;\n }\n const layers = this.tileLayerManager.getChilds(tile.layerIDList);\n this.tileLayerManager.updateLayersConfig(\n layers,\n 'visible',\n tile.isVisible,\n );\n }\n });\n\n if (this.tilesetManager.isLoaded) {\n // 将事件抛出,图层上可以使用瓦片\n this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);\n }\n }\n\n protected setPickState(layers: ILayer[]) {\n if (this.pickColors.select) {\n const selectedId = decodePickingColor(this.pickColors.select);\n layers.map((layer) => {\n this.selectFeature(layer, this.pickColors.select);\n layer.setCurrentSelectedId(selectedId);\n });\n }\n\n if (this.pickColors.active) {\n const selectedId = decodePickingColor(this.pickColors.active);\n layers\n .filter((layer) => layer.inited && layer.isVisible())\n .map((layer) => {\n layer.hooks.beforeHighlight.call(this.pickColors.active);\n layer.setCurrentPickId(selectedId);\n });\n }\n }\n\n private bindSubLayerPick() {\n this.tileLayerManager.tilePickManager.on('pick', (e) => {\n // @ts-ignore\n const [r, g, b] = e.pickedColors;\n\n if (e.type === 'click') {\n const restLayers = this.children\n .filter(\n (child) => child.inited && child.isVisible() && child.isVector,\n )\n .filter((child) => child !== e.layer);\n this.setSelect(restLayers, [r, g, b]);\n } else {\n this.setHighlight([r, g, b]);\n }\n });\n\n this.tileLayerManager.tilePickManager.on('unpick', () => {\n this.pickColors.active = null;\n });\n }\n\n private setHighlight(pickedColors: any) {\n const pickId = decodePickingColor(pickedColors);\n this.pickColors.active = pickedColors;\n this.children\n .filter((child) => child.inited && child.isVisible() && child.isVector)\n // Tip: 使用 vectorLayer 上的 pickID 优化高亮操作(过滤重复操作)\n // @ts-ignore\n .filter((child) => child.getPickID() !== pickId)\n .map((child) => {\n // @ts-ignore\n child.setPickID(pickId);\n child.hooks.beforeHighlight.call(pickedColors);\n });\n }\n\n private setSelect(layers: ILayer[], pickedColors: any) {\n const selectedId = decodePickingColor(pickedColors);\n layers.map((layer) => {\n if (\n layer.getCurrentSelectedId() === null ||\n selectedId !== layer.getCurrentSelectedId()\n ) {\n this.selectFeature(layer, pickedColors);\n layer.setCurrentSelectedId(selectedId);\n this.pickColors.select = pickedColors;\n } else {\n this.selectFeature(layer, new Uint8Array([0, 0, 0, 0])); // toggle select\n layer.setCurrentSelectedId(null);\n this.pickColors.select = null;\n }\n });\n // unselect normal layer\n const renderList = this.layerService.getRenderList();\n renderList\n .filter(\n (layer) =>\n layer.inited &&\n !layer.isVector &&\n layer.isVisible() &&\n layer.needPick('click'),\n )\n .filter((layer) => layer.getCurrentSelectedId() !== null)\n .map((layer) => {\n this.selectFeature(layer, new Uint8Array([0, 0, 0, 0]));\n layer.setCurrentSelectedId(null);\n });\n }\n\n private selectFeature(layer: ILayer, pickedColors: Uint8Array | undefined) {\n // @ts-ignore\n const [r, g, b] = pickedColors;\n layer.hooks.beforeSelect.call([r, g, b]);\n }\n\n private bindSubLayerEvent() {\n /**\n * layer.on('click', (ev) => {}); // 鼠标左键点击图层事件\n * layer.on('mouseenter', (ev) => {}); // 鼠标进入图层要素\n * layer.on('mousemove', (ev) => {}); // 鼠标在图层上移动时触发\n * layer.on('mouseout', (ev) => {}); // 鼠标移出图层要素时触发\n * layer.on('mouseup', (ev) => {}); // 鼠标在图层上单击抬起时触发\n * layer.on('mousedown', (ev) => {}); // 鼠标在图层上单击按下时触发\n * layer.on('contextmenu', (ev) => {}); // 图层要素点击右键菜单\n *\n * 鼠标在图层外的事件\n * layer.on('unclick', (ev) => {}); // 图层外点击\n * layer.on('unmousemove', (ev) => {}); // 图层外移动\n * layer.on('unmouseup', (ev) => {}); // 图层外鼠标抬起\n * layer.on('unmousedown', (ev) => {}); // 图层外单击按下时触发\n * layer.on('uncontextmenu', (ev) => {}); // 图层外点击右键\n * layer.on('unpick', (ev) => {}); // 图层外的操作的所有事件\n */\n this.parent.on('subLayerClick', (e) => {\n this.parent.emit('click', { ...e });\n });\n this.parent.on('subLayerMouseMove', (e) =>\n this.parent.emit('mousemove', { ...e }),\n );\n this.parent.on('subLayerMouseUp', (e) =>\n this.parent.emit('mouseup', { ...e }),\n );\n this.parent.on('subLayerMouseEnter', (e) =>\n this.parent.emit('mouseenter', { ...e }),\n );\n this.parent.on('subLayerMouseOut', (e) =>\n this.parent.emit('mouseout', { ...e }),\n );\n this.parent.on('subLayerMouseDown', (e) =>\n this.parent.emit('mousedown', { ...e }),\n );\n this.parent.on('subLayerContextmenu', (e) =>\n this.parent.emit('contextmenu', { ...e }),\n );\n\n // vector layer 图层外事件\n this.parent.on('subLayerUnClick', (e) =>\n this.parent.emit('unclick', { ...e }),\n );\n this.parent.on('subLayerUnMouseMove', (e) =>\n this.parent.emit('unmousemove', { ...e }),\n );\n this.parent.on('subLayerUnMouseUp', (e) =>\n this.parent.emit('unmouseup', { ...e }),\n );\n this.parent.on('subLayerUnMouseDown', (e) =>\n this.parent.emit('unmousedown', { ...e }),\n );\n this.parent.on('subLayerUnContextmenu', (e) =>\n this.parent.emit('uncontextmenu', { ...e }),\n );\n }\n\n private initTileSetManager() {\n const source: ISource = this.parent.getSource();\n this.tilesetManager = source.tileset as TilesetManager;\n\n if (!this.initedTileset) {\n this.bindTilesetEvent();\n this.initedTileset = true;\n }\n\n const { latLonBounds, zoom } = this.getCurrentView();\n this.tilesetManager?.update(zoom, latLonBounds);\n }\n\n private bindTilesetEvent() {\n if (!this.tilesetManager) {\n return;\n }\n // 瓦片数据加载成功\n this.tilesetManager.on('tile-loaded', (tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n });\n\n // 瓦片数据从缓存删除或被执行重新加载\n this.tilesetManager.on('tile-unload', (tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n this.tileUnLoad(tile);\n });\n\n // 瓦片数据加载失败\n this.tilesetManager.on('tile-error', (error, tile: Tile) => {\n // todo: 将事件抛出,图层上可以监听使用\n this.tileError(error);\n });\n\n // 瓦片显隐状态更新\n this.tilesetManager.on('tile-update', () => {\n this.tileUpdate();\n });\n\n // 地图视野发生改变\n this.mapService.on('mapchange', (e) => {\n const { latLonBounds, zoom } = this.getCurrentView();\n\n if (this.mapService.version === 'GAODE1.x') {\n const { visible } = this.parent.getLayerConfig();\n if (zoom < 3 && visible) {\n this.parent.updateLayerConfig({ visible: false });\n this.layerService.updateLayerRenderList();\n } else if (zoom >= 3 && !visible) {\n this.parent.updateLayerConfig({ visible: true });\n this.layerService.updateLayerRenderList();\n }\n }\n\n if (\n this.lastViewStates &&\n this.lastViewStates.zoom === zoom &&\n this.lastViewStates.latLonBounds.toString() === latLonBounds.toString()\n ) {\n return;\n }\n this.lastViewStates = { zoom, latLonBounds };\n\n if (this.timer) {\n clearTimeout(this.timer);\n this.timer = null;\n }\n\n this.timer = setTimeout(() => {\n this.tilesetManager?.update(zoom, latLonBounds);\n }, 250);\n });\n }\n\n private getCurrentView() {\n const bounds = this.mapService.getBounds();\n const latLonBounds: [number, number, number, number] = [\n bounds[0][0],\n bounds[0][1],\n bounds[1][0],\n bounds[1][1],\n ];\n const zoom = this.mapService.getZoom();\n\n return { latLonBounds, zoom };\n }\n}\n"],"file":"baseTileLayer.js"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
+
|
|
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); }; }
|
|
10
|
+
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
|
|
13
|
+
import BaseTileLayer from './tileLayer/baseTileLayer';
|
|
14
|
+
export var TMSTileLayer = function (_BaseTileLayer) {
|
|
15
|
+
_inherits(TMSTileLayer, _BaseTileLayer);
|
|
16
|
+
|
|
17
|
+
var _super = _createSuper(TMSTileLayer);
|
|
18
|
+
|
|
19
|
+
function TMSTileLayer() {
|
|
20
|
+
var _this;
|
|
21
|
+
|
|
22
|
+
_classCallCheck(this, TMSTileLayer);
|
|
23
|
+
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
29
|
+
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "type", 'TMS');
|
|
31
|
+
|
|
32
|
+
return _this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_createClass(TMSTileLayer, [{
|
|
36
|
+
key: "tileUnLoad",
|
|
37
|
+
value: function tileUnLoad(tile) {
|
|
38
|
+
this.tileLayerManager.removeChilds(tile.layerIDList);
|
|
39
|
+
}
|
|
40
|
+
}, {
|
|
41
|
+
key: "tileUpdate",
|
|
42
|
+
value: function tileUpdate() {
|
|
43
|
+
var _this2 = this;
|
|
44
|
+
|
|
45
|
+
if (!this.tilesetManager) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
this.tilesetManager.tiles.filter(function (tile) {
|
|
50
|
+
return tile.isLoaded;
|
|
51
|
+
}).map(function (tile) {
|
|
52
|
+
var _tile$data;
|
|
53
|
+
|
|
54
|
+
if ((_tile$data = tile.data) !== null && _tile$data !== void 0 && _tile$data.layers && _this2.sourceLayer) {
|
|
55
|
+
var vectorTileLayer = tile.data.layers[_this2.sourceLayer];
|
|
56
|
+
var features = vectorTileLayer === null || vectorTileLayer === void 0 ? void 0 : vectorTileLayer.features;
|
|
57
|
+
|
|
58
|
+
if (!(Array.isArray(features) && features.length > 0)) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!tile.layerIDList.includes(_this2.parent.id)) {
|
|
64
|
+
var _this2$tileLayerManag = _this2.tileLayerManager.createTile(tile),
|
|
65
|
+
layers = _this2$tileLayerManag.layers;
|
|
66
|
+
|
|
67
|
+
tile.layerIDList.push(_this2.parent.id);
|
|
68
|
+
|
|
69
|
+
_this2.tileLayerManager.addChilds(layers);
|
|
70
|
+
|
|
71
|
+
_this2.setPickState(layers);
|
|
72
|
+
} else {
|
|
73
|
+
if (!tile.isVisibleChanged) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var _layers = _this2.tileLayerManager.getChilds(tile.layerIDList);
|
|
78
|
+
|
|
79
|
+
_this2.tileLayerManager.updateLayersConfig(_layers, 'visible', tile.isVisible);
|
|
80
|
+
|
|
81
|
+
_this2.setPickState(_layers);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
this.parent.renderLayers();
|
|
85
|
+
|
|
86
|
+
if (this.tilesetManager.isLoaded) {
|
|
87
|
+
this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}]);
|
|
91
|
+
|
|
92
|
+
return TMSTileLayer;
|
|
93
|
+
}(BaseTileLayer);
|
|
94
|
+
//# sourceMappingURL=tmsTileLayer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/tile/tmsTileLayer.ts"],"names":["BaseTileLayer","TMSTileLayer","tile","tileLayerManager","removeChilds","layerIDList","tilesetManager","tiles","filter","isLoaded","map","data","layers","sourceLayer","vectorTileLayer","features","Array","isArray","length","includes","parent","id","createTile","push","addChilds","setPickState","isVisibleChanged","getChilds","updateLayersConfig","isVisible","renderLayers","emit","currentTiles"],"mappings":";;;;;;;;;;;;AACA,OAAOA,aAAP,MAA0B,2BAA1B;AAEA,WAAaC,YAAb;AAAA;;AAAA;;AAAA;AAAA;;AAAA;;AAAA;AAAA;AAAA;;AAAA;;AAAA,2DACwB,KADxB;;AAAA;AAAA;;AAAA;AAAA;AAAA,WAEE,oBAAkBC,IAAlB,EAA8B;AAC5B,WAAKC,gBAAL,CAAsBC,YAAtB,CAAmCF,IAAI,CAACG,WAAxC;AACD;AAJH;AAAA;AAAA,WAKE,sBAAoB;AAAA;;AAClB,UAAI,CAAC,KAAKC,cAAV,EAA0B;AACxB;AACD;;AACD,WAAKA,cAAL,CAAoBC,KAApB,CACGC,MADH,CACU,UAACN,IAAD;AAAA,eAAgBA,IAAI,CAACO,QAArB;AAAA,OADV,EAEGC,GAFH,CAEO,UAACR,IAAD,EAAgB;AAAA;;AACnB,YAAI,cAAAA,IAAI,CAACS,IAAL,kDAAWC,MAAX,IAAqB,MAAI,CAACC,WAA9B,EAA2C;AAEzC,cAAMC,eAAe,GAAGZ,IAAI,CAACS,IAAL,CAAUC,MAAV,CAAiB,MAAI,CAACC,WAAtB,CAAxB;AACA,cAAME,QAAQ,GAAGD,eAAH,aAAGA,eAAH,uBAAGA,eAAe,CAAEC,QAAlC;;AACA,cAAI,EAAEC,KAAK,CAACC,OAAN,CAAcF,QAAd,KAA2BA,QAAQ,CAACG,MAAT,GAAkB,CAA/C,CAAJ,EAAuD;AACrD;AACD;AACF;;AACD,YAAI,CAAChB,IAAI,CAACG,WAAL,CAAiBc,QAAjB,CAA0B,MAAI,CAACC,MAAL,CAAYC,EAAtC,CAAL,EAAgD;AAC9C,sCAAmB,MAAI,CAAClB,gBAAL,CAAsBmB,UAAtB,CAAiCpB,IAAjC,CAAnB;AAAA,cAAQU,MAAR,yBAAQA,MAAR;;AACAV,UAAAA,IAAI,CAACG,WAAL,CAAiBkB,IAAjB,CAAsB,MAAI,CAACH,MAAL,CAAYC,EAAlC;;AAEA,UAAA,MAAI,CAAClB,gBAAL,CAAsBqB,SAAtB,CAAgCZ,MAAhC;;AACA,UAAA,MAAI,CAACa,YAAL,CAAkBb,MAAlB;AACD,SAND,MAMO;AACL,cAAI,CAACV,IAAI,CAACwB,gBAAV,EAA4B;AAC1B;AACD;;AACD,cAAMd,OAAM,GAAG,MAAI,CAACT,gBAAL,CAAsBwB,SAAtB,CAAgCzB,IAAI,CAACG,WAArC,CAAf;;AACA,UAAA,MAAI,CAACF,gBAAL,CAAsByB,kBAAtB,CACEhB,OADF,EAEE,SAFF,EAGEV,IAAI,CAAC2B,SAHP;;AAKA,UAAA,MAAI,CAACJ,YAAL,CAAkBb,OAAlB;AACD;AACF,OA7BH;AA+BA,WAAKQ,MAAL,CAAYU,YAAZ;;AAEA,UAAI,KAAKxB,cAAL,CAAoBG,QAAxB,EAAkC;AAEhC,aAAKW,MAAL,CAAYW,IAAZ,CAAiB,cAAjB,EAAiC,KAAKzB,cAAL,CAAoB0B,YAArD;AACD;AACF;AA9CH;;AAAA;AAAA,EAAkChC,aAAlC","sourcesContent":["import { Tile, TilesetManager } from '@antv/l7-utils';\nimport BaseTileLayer from './tileLayer/baseTileLayer';\n\nexport class TMSTileLayer extends BaseTileLayer {\n public type: string = 'TMS';\n public tileUnLoad(tile: Tile) {\n this.tileLayerManager.removeChilds(tile.layerIDList);\n }\n public tileUpdate() {\n if (!this.tilesetManager) {\n return;\n }\n this.tilesetManager.tiles\n .filter((tile: Tile) => tile.isLoaded)\n .map((tile: Tile) => {\n if (tile.data?.layers && this.sourceLayer) {\n // vector\n const vectorTileLayer = tile.data.layers[this.sourceLayer];\n const features = vectorTileLayer?.features;\n if (!(Array.isArray(features) && features.length > 0)) {\n return;\n }\n }\n if (!tile.layerIDList.includes(this.parent.id)) {\n const { layers } = this.tileLayerManager.createTile(tile);\n tile.layerIDList.push(this.parent.id);\n\n this.tileLayerManager.addChilds(layers);\n this.setPickState(layers);\n } else {\n if (!tile.isVisibleChanged) {\n return;\n }\n const layers = this.tileLayerManager.getChilds(tile.layerIDList);\n this.tileLayerManager.updateLayersConfig(\n layers,\n 'visible',\n tile.isVisible,\n );\n this.setPickState(layers);\n }\n });\n\n this.parent.renderLayers();\n\n if (this.tilesetManager.isLoaded) {\n // 将事件抛出,图层上可以使用瓦片\n this.parent.emit('tiles-loaded', this.tilesetManager.currentTiles);\n }\n }\n}\n"],"file":"tmsTileLayer.js"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ILayer, IMapService, IRendererService } from '@antv/l7-core';
|
|
2
|
+
import { Tile } from '@antv/l7-utils';
|
|
3
|
+
export declare function registerLayers(parentLayer: ILayer, layers: ILayer[]): void;
|
|
4
|
+
export declare function getLayerShape(layerType: string, layer: ILayer): string | string[];
|
|
5
|
+
export declare function getMaskValue(layerType: string, mask: boolean): boolean;
|
|
6
|
+
export declare function getContainerSize(container: HTMLCanvasElement | HTMLElement): DOMRect | {
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
export declare function readRasterValue(tile: Tile, mapService: IMapService, x: number, y: number): any;
|
|
11
|
+
export declare function readPixel(x: number, y: number, rendererService: IRendererService): false | Uint8Array;
|