Question about getSelectedLayers API

In the sample source 2024.3.0, when user clicks the layer item in the model browser, it will trigger selectLayer API which trigger a clear selection and layer related nodes selection.

In LayersTree.js and TreeControl.js, I notice that when the latter selection triggers the selectionArray callback, the getSelectedLayers is still empty. So I would like to know if there is callback will be triggered when the getSelectedLayers reflects the actual situation?

I guess the async execution of _updateTreeSelectionHighlight in _doSelection in TreeControl.js is for handling my question.

// LayersTree.js
...
selectionArray: (events) => {
        if (this._layerNames.length === 0) {
          return;
        }
        this._tree.updateSelection(events);
...
}

// TreeControl.js
_doSelection(...) {
            this._selectionLabelHighlightTimer.set(30, () => {
                const selectionIds = this._viewer.selectionManager.getResults().map((item) => item.getNodeId());
                this._updateTreeSelectionHighlight(selectionIds);
            });
}

_updateLayerTreeSelectionHighlight(...) {
...
this._selectedLayers = this._viewer.selectionManager.getSelectedLayers();
}

Thank you

@nick.wong,

When the selectionArray callback is triggered, the class SelectionManager method getSelectedLayers returns null because layers is not part of the SelectionItem class . The SelectionItem class returns entities such as PointEntity, FaceEntity and LineEntity.

Perhaps the best way forward is for you to create a feature request in our Support Portal if this is functionality you are very interested in.