MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / _createLayerLegendList

Method _createLayerLegendList

src/common/mapping/WebMapV3.js:996–1109  ·  view source on GitHub ↗
(layer, styleSetting)

Source from the content-addressed store, hash-verified

994 }
995
996 _createLayerLegendList(layer, styleSetting) {
997 const layerId = layer.id;
998 const layerTitle = layer.title;
999 const textFieldName = styleSetting.type === 'text' && styleSetting.textField && styleSetting.textField.value.replace(/^\{|\}$/g, '');
1000 const commonStyleOptions = {
1001 themeField: layer.themeField || styleSetting.field,
1002 layerId,
1003 layerTitle
1004 };
1005 const renderType = styleSetting.type || layer.type;
1006 const legendRenderType = this._getLegendRenderType(renderType);
1007 const shape = this._getLegendShape(renderType, styleSetting);
1008 if (['heat', 'heat3D'].includes(renderType)) {
1009 const colorKeyMap = {
1010 heat: 'heatmap-color',
1011 heat3D: 'heatmap-extrusion-color'
1012 };
1013 const colors = this._heatColorToGradient((layer.paint || {})[colorKeyMap[renderType]]);
1014 return [
1015 {
1016 ...commonStyleOptions,
1017 styleGroup: [
1018 {
1019 style: {
1020 type: LEGEND_STYLE_TYPES.STYLE,
1021 shape,
1022 colors
1023 }
1024 }
1025 ]
1026 }
1027 ];
1028 }
1029 const styleKeys = LEGEND_STYLE_KEYS[legendRenderType];
1030 if (!styleKeys) {
1031 return;
1032 }
1033 const keys = this._transStyleKeys(renderType, styleKeys);
1034 this._transStyleSetting(renderType, styleSetting);
1035 const simpleStyle = this._getLegendSimpleStyle(styleSetting, keys);
1036 const simpleResData = this._parseLegendtyle({ legendRenderType, customValue: simpleStyle });
1037 let dataKeys = this._getDataDrivenStyleKeys(legendRenderType, keys, styleSetting);
1038 // 3D线,动画线
1039 if (legendRenderType === LEGEND_RENDER_TYPE.ANIMATELINE) {
1040 // isReplaceLineColor: 3D线,动画线:使用符号替换线颜色,图例中将不再显示线颜色
1041 const isReplaceLineColor = styleSetting.textureBlend.value === 'replace';
1042 const hasTexture = !!(styleSetting.symbolsContent.value && styleSetting.symbolsContent.value.symbolId);
1043 if (isReplaceLineColor && hasTexture) {
1044 dataKeys = dataKeys.filter((key) => key !== 'color')
1045 }
1046 } else {
1047 // 其他
1048 // isAllPic: 如果符号为图片,图例中将不再显示颜色
1049 const symbolTypes = MAP_LAYER_TYPE_2_SYMBOL_TYPE[layer.type];
1050 const isAllPic = this._isAllPictureSymbolSaved(symbolTypes, styleSetting.symbolsContent, this._spriteDatas);
1051 if(isAllPic) {
1052 dataKeys = dataKeys.filter((key) => key !== 'color')
1053 }

Callers 1

_createLegendInfoMethod · 0.95

Calls 15

_getLegendRenderTypeMethod · 0.95
_getLegendShapeMethod · 0.95
_heatColorToGradientMethod · 0.95
_transStyleKeysMethod · 0.95
_transStyleSettingMethod · 0.95
_getLegendSimpleStyleMethod · 0.95
_parseLegendtyleMethod · 0.95
_getSettingStyleMethod · 0.95
_getSettingCustomMethod · 0.95

Tested by

no test coverage detected