@@ -966,7 +966,7 @@ export class WebMap extends mapboxgl.Evented {
966966
967967 _isWebsymbolById ( id ) {
968968 const a = [ 'line-' , 'polygon-' , 'point-' ] ;
969- return a . some ( ( el ) => id ? .startsWith ( el ) ) ;
969+ return a . some ( ( el ) => id && id . startsWith ( el ) ) ;
970970 }
971971
972972 /**
@@ -983,17 +983,14 @@ export class WebMap extends mapboxgl.Evented {
983983 if ( this . _getIconById ( id ) ) {
984984 return true ;
985985 }
986- return spriteJson ?. [ id ] ? .sdf || false ;
986+ return spriteJson [ id ] && spriteJson [ id ] . sdf || false ;
987987 }
988988
989989 _isAllPicturePoint ( symbolsContent , spriteJson ) {
990- if ( ! symbolsContent ) {
991- return false ;
992- }
993990 if ( symbolsContent . type === 'simple' ) {
994- return ! this . _getSymbolSDFStatus ( symbolsContent ? .value . symbolId , spriteJson ) ;
991+ return ! this . _getSymbolSDFStatus ( symbolsContent . value . symbolId , spriteJson ) ;
995992 } else {
996- return [ ...symbolsContent ? .values , { value : symbolsContent ? .defaultValue } ]
993+ return [ ...symbolsContent . values , { value : symbolsContent . defaultValue } ]
997994 . filter ( ( v ) => v . value . symbolId )
998995 . every ( ( v ) => {
999996 return ! this . _getSymbolSDFStatus ( v . value . symbolId , spriteJson ) ;
@@ -1002,15 +999,15 @@ export class WebMap extends mapboxgl.Evented {
1002999 }
10031000
10041001 _isAllPictureSymbolSaved ( symbolType , symbolsContent , spriteJson ) {
1002+ if ( ! symbolsContent ) {
1003+ return false ;
1004+ }
10051005 if ( symbolType === 'point' ) {
10061006 return this . _isAllPicturePoint ( symbolsContent , spriteJson ) ;
10071007 }
1008- if ( ! symbolsContent || ! symbolsContent . value ) {
1009- return false ;
1010- }
10111008 const currentType = symbolsContent . type ;
10121009 if ( currentType === 'simple' ) {
1013- return ! ! this . _getImageIdFromValue ( symbolsContent ? .value ? .style , SymbolType [ symbolType ] ) . length ;
1010+ return ! ! this . _getImageIdFromValue ( symbolsContent . value . style , SymbolType [ symbolType ] ) . length ;
10141011 }
10151012 const styles = ( symbolsContent . values ) . map ( ( v ) => v . value ) . concat ( symbolsContent . defaultValue ) ;
10161013 return styles . every ( ( v ) => {
@@ -1059,16 +1056,24 @@ export class WebMap extends mapboxgl.Evented {
10591056 const simpleStyle = this . _getLegendSimpleStyle ( styleSetting , keys ) ;
10601057 const simpleResData = this . _parseLegendtyle ( { legendRenderType, customValue : simpleStyle } ) ;
10611058 let dataKeys = keys . filter ( ( k ) => styleSetting [ k ] && styleSetting [ k ] . type !== 'simple' ) ;
1062- // isReplaceLineColor: 3D线,动画线:使用符号替换线颜色,图例中将不再显示线颜色
1063- const isReplaceLineColor = styleSetting . textureBlend ?. value === 'replace' ;
1064- const hasTexture = ! ! styleSetting . symbolsContent ?. value ?. symbolId ;
1065- // isAllPic: 如果符号为图片,图例中将不再显示颜色
1066- const symbolTypes = MAP_LAYER_TYPE_2_SYMBOL_TYPE [ layer . type ] ;
1067- const isAllPic = this . _isAllPictureSymbolSaved ( symbolTypes , styleSetting . symbolsContent , this . _spriteDatas ) ;
1068- if ( ( isReplaceLineColor && hasTexture ) || isAllPic ) {
1069- dataKeys = dataKeys . filter ( ( key ) => key !== 'color' )
1059+ // 3D线,动画线
1060+ if ( legendRenderType === LEGEND_RENDER_TYPE . ANIMATELINE ) {
1061+ // isReplaceLineColor: 3D线,动画线:使用符号替换线颜色,图例中将不再显示线颜色
1062+ const isReplaceLineColor = styleSetting . textureBlend . value === 'replace' ;
1063+ const hasTexture = ! ! ( styleSetting . symbolsContent . value && styleSetting . symbolsContent . value . symbolId ) ;
1064+ if ( isReplaceLineColor && hasTexture ) {
1065+ dataKeys = dataKeys . filter ( ( key ) => key !== 'color' )
1066+ }
1067+ } else {
1068+ // 其他
1069+ // isAllPic: 如果符号为图片,图例中将不再显示颜色
1070+ const symbolTypes = MAP_LAYER_TYPE_2_SYMBOL_TYPE [ layer . type ] ;
1071+ const isAllPic = this . _isAllPictureSymbolSaved ( symbolTypes , styleSetting . symbolsContent , this . _spriteDatas ) ;
1072+ if ( isAllPic ) {
1073+ dataKeys = dataKeys . filter ( ( key ) => key !== 'color' )
1074+ }
10701075 }
1071- const isLinearColor = styleSetting . color ? .interpolateInfo ? .type === 'linear' ;
1076+ const isLinearColor = styleSetting . color . interpolateInfo && styleSetting . color . interpolateInfo . type === 'linear' ;
10721077 const isShowSingleItem = this . _isShowLegendSingleItem ( dataKeys , isLinearColor ) ;
10731078 const resultList = [ ] ;
10741079 if ( isShowSingleItem ) {
@@ -1362,11 +1367,11 @@ export class WebMap extends mapboxgl.Evented {
13621367 const styles = Array . isArray ( style ) ? style : [ style ] ;
13631368 const imageKey = imageKeys [ type ] ;
13641369 if ( type === 'symbol' ) {
1365- const imageIds = styles . map ( ( item ) => item . layout ?. [ imageKey ] ) ;
1370+ const imageIds = styles . map ( ( item ) => item . layout && item . layout [ imageKey ] ) ;
13661371 return imageIds . filter ( ( id ) => id ) ;
13671372 }
13681373 // 'line' 'fill' 'fill-extrusion'
1369- const imageIds = styles . map ( ( item ) => item . paint ?. [ imageKey ] ) ;
1374+ const imageIds = styles . map ( ( item ) => item . paint && item . paint [ imageKey ] ) ;
13701375 return imageIds . filter ( ( id ) => id ) ;
13711376}
13721377
0 commit comments