MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / getSymbolStyle

Method getSymbolStyle

src/openlayers/core/StyleUtils.js:1061–1098  ·  view source on GitHub ↗

* @function StyleUtils.getSymbolStyle 获取符号样式 * @param {Object} parameters - 样式参数 * @returns {Object} style对象

(parameters, isRank)

Source from the content-addressed store, hash-verified

1059 * @returns {Object} style对象
1060 */
1061 static getSymbolStyle(parameters, isRank) {
1062 let text = '';
1063 if (parameters.unicode) {
1064 text = String.fromCharCode(parseInt(parameters.unicode.replace(/^&#x/, ''), 16));
1065 }
1066 // 填充色 + 透明度
1067 let fillColor = StyleUtils.hexToRgb(parameters.fillColor);
1068 fillColor.push(parameters.fillOpacity);
1069 // 边框充色 + 透明度
1070 let strokeColor = StyleUtils.hexToRgb(parameters.strokeColor);
1071 strokeColor.push(parameters.strokeOpacity);
1072
1073 let fontSize = isRank ? 2 * parameters.radius + "px" : parameters.fontSize;
1074
1075 const {offsetX, offsetY, rotation=0} = parameters;
1076 const offset = StyleUtils.getTextOffset(fontSize, offsetX, offsetY);
1077 return new Style({
1078 text: new Text({
1079 text: text,
1080 font: fontSize + " supermapol-icons",
1081 placement: 'point',
1082 textAlign: 'center',
1083 fill: new FillStyle({
1084 color: fillColor
1085 }),
1086 backgroundFill: new FillStyle({
1087 color: [0, 0, 0, 0]
1088 }),
1089 stroke: new StrokeStyle({
1090 width: parameters.strokeWidth || 0.000001,
1091 color: strokeColor
1092 }),
1093 offsetX: offset.x,
1094 offsetY: offset.y,
1095 rotation
1096 })
1097 });
1098 }
1099 /**
1100 * @function StyleUtils.getSVGStyle 获取svg的样式
1101 * @param {Object} styleParams - 样式参数

Callers 4

getOpenlayersStyleMethod · 0.95
StyleUtils2Spec.jsFile · 0.80
createSymbolLayerMethod · 0.80
getUniqueStyleGroupMethod · 0.80

Calls 3

hexToRgbMethod · 0.80
pushMethod · 0.80
getTextOffsetMethod · 0.80

Tested by

no test coverage detected