11
22import { AppreciableLayerBase } from './AppreciableLayerBase' ;
3- import { getLayerInfosFromCatalogs } from './util' ;
3+ import { getLayerCatalogRenderLayers , getLayerInfosFromCatalogs , getMainLayerFromCatalog } from './util' ;
44
55export class SourceListModelV3 extends AppreciableLayerBase {
66 constructor ( options = { } ) {
@@ -50,7 +50,7 @@ export class SourceListModelV3 extends AppreciableLayerBase {
5050 _createSourceCatalogs ( catalogs , appreciableLayers ) {
5151 const formatCatalogs = catalogs . map ( ( catalog ) => {
5252 let formatItem ;
53- const { id, title = id , type, visible, children } = catalog ;
53+ const { id, title = id , type, visible, children, parts } = catalog ;
5454 if ( type === 'group' ) {
5555 formatItem = {
5656 children : this . _createSourceCatalogs ( children , appreciableLayers ) ,
@@ -60,7 +60,8 @@ export class SourceListModelV3 extends AppreciableLayerBase {
6060 visible
6161 } ;
6262 } else {
63- const matchLayer = appreciableLayers . find ( ( layer ) => layer . id === id ) ;
63+ const renderLayers = getLayerCatalogRenderLayers ( parts , id , this . _mapInfo . layers ) ;
64+ const matchLayer = appreciableLayers . find ( ( layer ) => layer . id === renderLayers [ 0 ] ) ;
6465 this . removeLayerExtralFields ( [ matchLayer ] ) ;
6566 formatItem = Object . assign ( { } , matchLayer ) ;
6667 }
@@ -75,8 +76,9 @@ export class SourceListModelV3 extends AppreciableLayerBase {
7576 const metadataCatalogs = getLayerInfosFromCatalogs ( this . _mapInfo . metadata . layerCatalog ) ;
7677 const l7MarkerLayers = this . _l7LayerUtil . getL7MarkerLayers ( ) ;
7778 const layerDatas = metadataCatalogs . map ( layerCatalog => {
78- const layer = this . _mapInfo . layers . find ( item => item . id === layerCatalog . id ) || { } ;
79- const layerInfo = { id : layer . id , title : layerCatalog . title , renderLayers : this . _getRenderLayers ( layerCatalog . parts , layerCatalog . id ) , reused : layer . metadata && layer . metadata . reused } ;
79+ const renderLayers = getLayerCatalogRenderLayers ( layerCatalog . parts , layerCatalog . id , this . _mapInfo . layers ) ;
80+ const layer = getMainLayerFromCatalog ( layerCatalog . parts , layerCatalog . id , this . _mapInfo . layers ) ;
81+ const layerInfo = { id : layer . id , title : layerCatalog . title , renderLayers, reused : layer . metadata && layer . metadata . reused } ;
8082 const matchProjectCatalog = projectCataglogs . find ( ( item ) => item . id === layerCatalog . id ) || { } ;
8183 const { msDatasetId } = matchProjectCatalog ;
8284 let dataSource = { } ;
@@ -133,16 +135,4 @@ export class SourceListModelV3 extends AppreciableLayerBase {
133135 layerDatas . reverse ( ) ;
134136 return layerDatas ;
135137 }
136-
137- _getRenderLayers ( layerIds , layerId ) {
138- if ( layerIds ) {
139- if ( layerIds . includes ( layerId ) ) {
140- return layerIds ;
141- } else {
142- return [ layerId , ...layerIds ] ;
143- }
144- } else {
145- return [ layerId ] ;
146- }
147- }
148138}
0 commit comments