* @function StyleUtils.getSymbolStyle 获取符号样式 * @param {Object} parameters - 样式参数 * @returns {Object} style对象
(parameters, isRank)
| 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 - 样式参数 |
no test coverage detected