@@ -42,12 +42,6 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
42
42
this . _appendLayers = false ;
43
43
}
44
44
45
- /**
46
- * @private
47
- * @function WebMapV2.prototype.initializeMap
48
- * @description 登陆窗口后添加地图图层。
49
- * @param {Object } mapInfo - map 信息。
50
- */
51
45
initializeMap ( mapInfo , map ) {
52
46
if ( map ) {
53
47
this . _appendLayers = true ;
@@ -2226,7 +2220,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
2226
2220
}
2227
2221
2228
2222
_rectifyLayersOrder ( appreciableLayers , topLayerBeforeId ) {
2229
- const renderLayers = appreciableLayers . reduce ( ( layers , layer ) => {
2223
+ const renderLayers = appreciableLayers . filter ( item => ! item . reused ) . reduce ( ( layers , layer ) => {
2230
2224
return layers . concat ( layer . renderLayers ) ;
2231
2225
} , [ ] ) ;
2232
2226
const labelLayerIds = [ ] ;
@@ -2726,7 +2720,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
2726
2720
const { id } = layerInfo ;
2727
2721
if ( this . map . getLayer ( id ) ) {
2728
2722
if ( this . checkSameLayer && this . _isSameRasterLayer ( id , layerInfo ) ) {
2729
- this . _setCacheLayer ( { layerInfo, parentLayerId, id, ignore : true , beforeId } ) ;
2723
+ this . _setCacheLayer ( { layerInfo, parentLayerId, id, reused : true , beforeId } ) ;
2730
2724
return ;
2731
2725
}
2732
2726
this . _updateLayer ( layerInfo ) ;
@@ -2737,8 +2731,8 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
2737
2731
this . _setCacheLayer ( { layerInfo, parentLayerId, id, beforeId } ) ;
2738
2732
}
2739
2733
2740
- _setCacheLayer ( { parentLayerId, layerInfo, ignore = false , beforeId, subRenderLayers } ) {
2741
- const renderLayers = subRenderLayers || [ { layerId : layerInfo . id , ignore } ] ;
2734
+ _setCacheLayer ( { parentLayerId, layerInfo, reused = false , beforeId, subRenderLayers } ) {
2735
+ const renderLayers = subRenderLayers || [ { layerId : layerInfo . id , reused } ] ;
2742
2736
if ( ! this . _cacheLayerId . has ( parentLayerId ) ) {
2743
2737
this . _cacheLayerId . set ( parentLayerId , renderLayers ) ;
2744
2738
} else {
@@ -2763,22 +2757,23 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
2763
2757
layerInfo . visible === void 0 || layerInfo . visible === 'visible' || layerInfo . visible === true ;
2764
2758
const matchLayers = this . _cacheLayerId . get ( targetLayerId ) ;
2765
2759
if ( matchLayers ) {
2766
- const renderLayers = matchLayers . filter ( ( item ) => ! item . ignore ) . map ( ( item ) => item . layerId ) ;
2760
+ const renderLayers = matchLayers . map ( ( item ) => item . layerId ) ;
2767
2761
if ( ! renderLayers . length ) {
2768
2762
return ;
2769
2763
}
2770
2764
layersFromMapInfo . push ( {
2771
2765
...layerInfo ,
2772
2766
id : targetLayerId ,
2773
2767
visible : targetLayerVisible ,
2774
- renderLayers
2768
+ renderLayers,
2769
+ reused : matchLayers . some ( item => item . reused ) || void 0
2775
2770
} ) ;
2776
2771
}
2777
2772
} ) ;
2778
2773
this . _changeSourceListModel ( layersFromMapInfo ) ;
2779
2774
const appreciableLayers = this . getLayers ( ) ;
2780
2775
if ( this . addLayersSucceededLen && this . _cacheLayerId . size !== this . addLayersSucceededLen ) {
2781
- const selfAppreciableLayers = this . getSelfAppreciableLayers ( appreciableLayers )
2776
+ const selfAppreciableLayers = this . getSelfAppreciableLayers ( appreciableLayers ) ;
2782
2777
const topLayerBeforeId = this . _findTopLayerBeforeId ( selfAppreciableLayers ) ;
2783
2778
this . _rectifyLayersOrder ( selfAppreciableLayers , topLayerBeforeId ) ;
2784
2779
this . addLayersSucceededLen = this . _cacheLayerId . size ;
@@ -2788,7 +2783,7 @@ export function createWebMapV2Extending(SuperClass, { MapManager, mapRepo }) {
2788
2783
2789
2784
_findTopLayerBeforeId ( selfAppreciableLayers ) {
2790
2785
// fix 追加图层,异步的图层回来排序错乱
2791
- const selfLayerIds = selfAppreciableLayers . reduce ( ( ids , item ) => ids . concat ( item . renderLayers ) , [ ] ) ;
2786
+ const selfLayerIds = selfAppreciableLayers . filter ( item => ! item . reused ) . reduce ( ( ids , item ) => ids . concat ( item . renderLayers ) , [ ] ) ;
2792
2787
const firstSelfLayerIdOnMap = selfLayerIds . find ( ( id ) => this . map . style . _layers [ id ] ) ;
2793
2788
if ( ! firstSelfLayerIdOnMap ) {
2794
2789
return ;
0 commit comments