MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / _setCacheLayer

Method _setCacheLayer

src/common/mapping/WebMapV2.js:3015–3037  ·  view source on GitHub ↗
({ parentLayerId, layerInfo, reused = false, beforeId, subRenderLayers, metadata })

Source from the content-addressed store, hash-verified

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 追加图层,异步的图层回来排序错乱

Callers 3

_createMVTBaseLayerMethod · 0.95
_initGraticuleLayerMethod · 0.95
_addLayerMethod · 0.95

Calls 9

_findTopLayerBeforeIdMethod · 0.95
rectifyLayersOrderMethod · 0.95
setMethod · 0.45
getMethod · 0.45
getLayersMethod · 0.45
fireMethod · 0.45

Tested by

no test coverage detected