@@ -196,7 +196,7 @@ export class WebMap extends mapboxgl.Evented {
196196
197197 async copyLayer ( id , layerInfo = { } ) {
198198 const matchLayer = this . _mapInfo . layers . find ( layer => layer . id === id ) ;
199- if ( ! matchLayer || this . map . getLayer ( layerInfo . id ) ) {
199+ if ( ! matchLayer || this . getLayerOnMap ( layerInfo . id ) ) {
200200 return ;
201201 }
202202 const copyLayerId = layerInfo . id || `${ matchLayer . id } _copy` ;
@@ -496,7 +496,7 @@ export class WebMap extends mapboxgl.Evented {
496496 }
497497 for ( const layer of layersToMap ) {
498498 const originId = layer . id ;
499- if ( this . map . getLayer ( layer . id ) ) {
499+ if ( this . getLayerOnMap ( layer . id ) ) {
500500 const layerId = layer . id + timestamp ;
501501 layer . id = layerId ;
502502 }
@@ -526,6 +526,34 @@ export class WebMap extends mapboxgl.Evented {
526526 } ;
527527 }
528528
529+ getLayerOnMap ( layerId ) {
530+ const overlayLayer = this . map . overlayLayersManager [ layerId ] ;
531+ if ( overlayLayer ) {
532+ return overlayLayer ;
533+ }
534+ const l7MarkerLayers = getL7MarkerLayers ( ) ;
535+ const l7MarkerLayer = l7MarkerLayers [ layerId ] ;
536+ if ( l7MarkerLayer ) {
537+ return l7MarkerLayer ;
538+ }
539+ return this . map . getLayer ( layerId ) ;
540+ }
541+
542+ _findLayerCatalog ( items , id ) {
543+ for ( const item of items ) {
544+ if ( item . id === id ) {
545+ return item ;
546+ }
547+ if ( item . children ) {
548+ const found = this . _findLayerCatalog ( item . children , id ) ;
549+ if ( found ) {
550+ return found ;
551+ }
552+ }
553+ }
554+ return null ;
555+ }
556+
529557 _deleteLayerCatalog ( catalogs , id ) {
530558 for ( let index = 0 ; index < catalogs . length ; index ++ ) {
531559 const catalog = catalogs [ index ] ;
@@ -539,14 +567,20 @@ export class WebMap extends mapboxgl.Evented {
539567 }
540568 }
541569
542- _updateLayerCatalogsId ( { loopData, catalogs, layerIdMapList, catalogTypeField = 'type' , layerIdsField = 'parts' , unspportedLayers } ) {
570+ _updateLayerCatalogsId ( {
571+ loopData,
572+ catalogs,
573+ layerIdMapList,
574+ catalogTypeField = 'type' ,
575+ layerIdsField = 'parts' ,
576+ unspportedLayers
577+ } ) {
543578 loopData . forEach ( ( loopItem ) => {
544- const catalog = catalogs . find ( item => item . id === loopItem . id ) ;
545- const { id, children } = catalog ;
546- if ( catalog [ catalogTypeField ] === 'group' ) {
579+ const { id, children } = loopItem ;
580+ if ( loopItem [ catalogTypeField ] === 'group' ) {
547581 this . _updateLayerCatalogsId ( {
548582 loopData : children ,
549- catalogs : children ,
583+ catalogs,
550584 layerIdMapList,
551585 catalogTypeField,
552586 layerIdsField,
@@ -556,6 +590,7 @@ export class WebMap extends mapboxgl.Evented {
556590 }
557591 const matchLayer = layerIdMapList . find ( ( item ) => item . originId === id ) ;
558592 if ( matchLayer ) {
593+ const catalog = this . _findLayerCatalog ( catalogs , id ) ;
559594 catalog . id = matchLayer . renderId ;
560595 if ( catalog [ layerIdsField ] ) {
561596 catalog [ layerIdsField ] = this . _renameLayerIdsContent ( catalog [ layerIdsField ] , layerIdMapList ) ;
@@ -683,6 +718,7 @@ export class WebMap extends mapboxgl.Evented {
683718 const { catalogs = [ ] , datas = [ ] } = this . _mapResourceInfo ;
684719 const projectCataglogs = this . _getLayerInfosFromCatalogs ( catalogs , 'catalogType' ) ;
685720 const metadataCatalogs = this . _getLayerInfosFromCatalogs ( this . _mapInfo . metadata . layerCatalog ) ;
721+ const l7MarkerLayers = getL7MarkerLayers ( ) ;
686722 const layers = allLayersOnMap . reduce ( ( layersList , layer ) => {
687723 const containLayer = metadataCatalogs . find ( ( item ) => {
688724 if ( item . parts && item . id !== layer . id ) {
@@ -743,6 +779,9 @@ export class WebMap extends mapboxgl.Evented {
743779 dataSource,
744780 themeSetting : { }
745781 } ) ;
782+ if ( l7MarkerLayers [ layer . id ] ) {
783+ overlayLayers . l7MarkerLayer = l7MarkerLayers [ layer . id ] ;
784+ }
746785 if ( isL7Layer ( layer ) ) {
747786 overlayLayers . l7Layer = true ;
748787 }
@@ -813,6 +852,9 @@ export class WebMap extends mapboxgl.Evented {
813852 if ( l7MarkerLayers [ id ] ) {
814853 formatItem . l7MarkerLayer = l7MarkerLayers [ id ] ;
815854 }
855+ if ( matchLayer . l7Layer ) {
856+ formatItem . l7Layer = matchLayer . l7Layer ;
857+ }
816858 }
817859 return formatItem ;
818860 } ) ;
@@ -1106,7 +1148,7 @@ export class WebMap extends mapboxgl.Evented {
11061148 if ( currentType === 'simple' ) {
11071149 return ! ! this . _getImageIdFromValue ( symbolsContent . value . style , SymbolType [ symbolType ] ) . length ;
11081150 }
1109- const styles = ( symbolsContent . values ) . map ( ( v ) => v . value ) . concat ( symbolsContent . defaultValue ) ;
1151+ const styles = symbolsContent . values . map ( ( v ) => v . value ) . concat ( symbolsContent . defaultValue ) ;
11101152 return styles . every ( ( v ) => {
11111153 return ! ! this . _getImageIdFromValue ( v . style , SymbolType [ symbolType ] ) . length ;
11121154 } ) ;
0 commit comments