@@ -196,7 +196,7 @@ export class WebMap extends mapboxgl.Evented {
196
196
197
197
async copyLayer ( id , layerInfo = { } ) {
198
198
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 ) ) {
200
200
return ;
201
201
}
202
202
const copyLayerId = layerInfo . id || `${ matchLayer . id } _copy` ;
@@ -496,7 +496,7 @@ export class WebMap extends mapboxgl.Evented {
496
496
}
497
497
for ( const layer of layersToMap ) {
498
498
const originId = layer . id ;
499
- if ( this . map . getLayer ( layer . id ) ) {
499
+ if ( this . getLayerOnMap ( layer . id ) ) {
500
500
const layerId = layer . id + timestamp ;
501
501
layer . id = layerId ;
502
502
}
@@ -526,6 +526,34 @@ export class WebMap extends mapboxgl.Evented {
526
526
} ;
527
527
}
528
528
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
+
529
557
_deleteLayerCatalog ( catalogs , id ) {
530
558
for ( let index = 0 ; index < catalogs . length ; index ++ ) {
531
559
const catalog = catalogs [ index ] ;
@@ -539,14 +567,20 @@ export class WebMap extends mapboxgl.Evented {
539
567
}
540
568
}
541
569
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
+ } ) {
543
578
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' ) {
547
581
this . _updateLayerCatalogsId ( {
548
582
loopData : children ,
549
- catalogs : children ,
583
+ catalogs,
550
584
layerIdMapList,
551
585
catalogTypeField,
552
586
layerIdsField,
@@ -556,6 +590,7 @@ export class WebMap extends mapboxgl.Evented {
556
590
}
557
591
const matchLayer = layerIdMapList . find ( ( item ) => item . originId === id ) ;
558
592
if ( matchLayer ) {
593
+ const catalog = this . _findLayerCatalog ( catalogs , id ) ;
559
594
catalog . id = matchLayer . renderId ;
560
595
if ( catalog [ layerIdsField ] ) {
561
596
catalog [ layerIdsField ] = this . _renameLayerIdsContent ( catalog [ layerIdsField ] , layerIdMapList ) ;
@@ -683,6 +718,7 @@ export class WebMap extends mapboxgl.Evented {
683
718
const { catalogs = [ ] , datas = [ ] } = this . _mapResourceInfo ;
684
719
const projectCataglogs = this . _getLayerInfosFromCatalogs ( catalogs , 'catalogType' ) ;
685
720
const metadataCatalogs = this . _getLayerInfosFromCatalogs ( this . _mapInfo . metadata . layerCatalog ) ;
721
+ const l7MarkerLayers = getL7MarkerLayers ( ) ;
686
722
const layers = allLayersOnMap . reduce ( ( layersList , layer ) => {
687
723
const containLayer = metadataCatalogs . find ( ( item ) => {
688
724
if ( item . parts && item . id !== layer . id ) {
@@ -743,6 +779,9 @@ export class WebMap extends mapboxgl.Evented {
743
779
dataSource,
744
780
themeSetting : { }
745
781
} ) ;
782
+ if ( l7MarkerLayers [ layer . id ] ) {
783
+ overlayLayers . l7MarkerLayer = l7MarkerLayers [ layer . id ] ;
784
+ }
746
785
if ( isL7Layer ( layer ) ) {
747
786
overlayLayers . l7Layer = true ;
748
787
}
@@ -813,6 +852,9 @@ export class WebMap extends mapboxgl.Evented {
813
852
if ( l7MarkerLayers [ id ] ) {
814
853
formatItem . l7MarkerLayer = l7MarkerLayers [ id ] ;
815
854
}
855
+ if ( matchLayer . l7Layer ) {
856
+ formatItem . l7Layer = matchLayer . l7Layer ;
857
+ }
816
858
}
817
859
return formatItem ;
818
860
} ) ;
@@ -1106,7 +1148,7 @@ export class WebMap extends mapboxgl.Evented {
1106
1148
if ( currentType === 'simple' ) {
1107
1149
return ! ! this . _getImageIdFromValue ( symbolsContent . value . style , SymbolType [ symbolType ] ) . length ;
1108
1150
}
1109
- const styles = ( symbolsContent . values ) . map ( ( v ) => v . value ) . concat ( symbolsContent . defaultValue ) ;
1151
+ const styles = symbolsContent . values . map ( ( v ) => v . value ) . concat ( symbolsContent . defaultValue ) ;
1110
1152
return styles . every ( ( v ) => {
1111
1153
return ! ! this . _getImageIdFromValue ( v . style , SymbolType [ symbolType ] ) . length ;
1112
1154
} ) ;
0 commit comments