({ parentLayerId, layerInfo, reused = false, beforeId, subRenderLayers, metadata })
| 3013 | } |
| 3014 | |
| 3015 | _setCacheLayer({ parentLayerId, layerInfo, reused = false, beforeId, subRenderLayers, metadata }) { |
| 3016 | const renderLayers = subRenderLayers || [{ layerId: layerInfo.id, reused }]; |
| 3017 | if (!this._cacheLayerId.has(parentLayerId)) { |
| 3018 | const metadataInfo = Object.assign({}, metadata || layerInfo && layerInfo.metadata, { SM_Layer_Id: parentLayerId }); |
| 3019 | this._cacheLayerId.set(parentLayerId, { renderLayers, metadata: metadataInfo }); |
| 3020 | } else { |
| 3021 | const layerCacheData = this._cacheLayerId.get(parentLayerId); |
| 3022 | let matchIndex = -1; |
| 3023 | if (beforeId) { |
| 3024 | matchIndex = layerCacheData.renderLayers.findIndex((item) => item.layerId === beforeId); |
| 3025 | } |
| 3026 | const matchInsertIndex = matchIndex < 0 ? layerCacheData.renderLayers.length : matchIndex; |
| 3027 | layerCacheData.renderLayers.splice(matchInsertIndex, 0, ...renderLayers); |
| 3028 | } |
| 3029 | if (this.addLayersSucceededLen && this._cacheLayerId.size <= this.expectLayerLen) { |
| 3030 | this._changeSourceListModel(); |
| 3031 | const appreciableLayers = this.getLayers(); |
| 3032 | const selfAppreciableLayers = this.getSelfAppreciableLayers(appreciableLayers); |
| 3033 | const topLayerBeforeId = this._findTopLayerBeforeId(selfAppreciableLayers); |
| 3034 | this.rectifyLayersOrder(selfAppreciableLayers, topLayerBeforeId); |
| 3035 | this.fire('layeraddchanged', this._getSelfAppreciableLayers(appreciableLayers)); |
| 3036 | } |
| 3037 | } |
| 3038 | |
| 3039 | _findTopLayerBeforeId(selfAppreciableLayers) { |
| 3040 | // fix 追加图层,异步的图层回来排序错乱 |
no test coverage detected