* @function StyleUtils.getRoadPath 获取道路样式 * @param {Object} style - 样式参数 * @param {Object} outlineStyle - 轮廓样式参数 * @returns {Object} style对象
(style, outlineStyle)
| 1179 | * @returns {Object} style对象 |
| 1180 | */ |
| 1181 | static getRoadPath(style, outlineStyle) { |
| 1182 | const { strokeWidth=ZERO, lineCap, strokeColor, strokeOpacity } = style; |
| 1183 | // 道路线都是solid |
| 1184 | let strokeColorArray = this.hexToRgb(strokeColor); |
| 1185 | strokeColorArray && strokeColorArray.push(strokeOpacity); |
| 1186 | var stroke = new Style({ |
| 1187 | stroke: new StrokeStyle({ |
| 1188 | width: strokeWidth || ZERO, |
| 1189 | color: strokeColorArray, |
| 1190 | lineCap: lineCap || 'round', |
| 1191 | lineDash: [0] |
| 1192 | }) |
| 1193 | }); |
| 1194 | |
| 1195 | const { strokeColor: outlineColor } = outlineStyle; |
| 1196 | let outlineColorArray = this.hexToRgb(outlineColor); |
| 1197 | // opacity使用style的透明度。保持两根线透明度一致 |
| 1198 | outlineColorArray && outlineColorArray.push(strokeOpacity); |
| 1199 | let outlineWidth = outlineStyle.strokeWidth || (strokeWidth === 0 ? ZERO : strokeWidth + 2); //外部宽度=内部样式宽度 + 2 |
| 1200 | var outlineStroke = new Style({ |
| 1201 | stroke: new StrokeStyle({ |
| 1202 | width: outlineWidth, //外部宽度=内部样式宽度 + 2 |
| 1203 | color: outlineColorArray, |
| 1204 | lineCap: lineCap || 'round', |
| 1205 | lineDash: [0] |
| 1206 | }) |
| 1207 | }); |
| 1208 | return [outlineStroke, stroke]; |
| 1209 | } |
| 1210 | /** |
| 1211 | * @function StyleUtils.getPathway 获取铁路样式 |
| 1212 | * @param {Object} style - 样式参数 |
no test coverage detected