Skip to content

Commit dd7d869

Browse files
committed
【feature】图层列表查询layer优化
1 parent 36b9900 commit dd7d869

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/common/mapping/utils/AppreciableLayerBase.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,19 @@ export class AppreciableLayerBase extends Events {
245245
return fields;
246246
}
247247

248-
_findLayerCatalog(layerCatalogs, id) {
249-
let matchData;
250-
for (const data of layerCatalogs) {
251-
if (data.id === id) {
252-
matchData = data;
253-
break;
248+
_findLayerCatalog(layerCatalogs, targetId) {
249+
for (const layer of layerCatalogs) {
250+
if (layer.id === targetId) {
251+
return layer;
254252
}
255-
if (data.type === 'group') {
256-
matchData = this._findLayerCatalog(data.children, id);
253+
if (layer.children && layer.children.length > 0) {
254+
const found = this._findLayerCatalog(layer.children, targetId);
255+
if (found) {
256+
return found;
257+
}
257258
}
258259
}
259-
return matchData;
260+
return null;
260261
}
261262

262263
_getLayerVisibleId(layer) {

0 commit comments

Comments
 (0)