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

Method getPathway

src/openlayers/core/StyleUtils.js:1216–1243  ·  view source on GitHub ↗

* @function StyleUtils.getPathway 获取铁路样式 * @param {Object} style - 样式参数 * @param {Object} outlineStyle - 轮廓样式参数 * @returns {Object} style对象

(style, outlineStyle)

Source from the content-addressed store, hash-verified

1214 * @returns {Object} style对象
1215 */
1216 static getPathway(style, outlineStyle) {
1217 let { strokeWidth=ZERO, strokeColor, strokeOpacity } = style;
1218 // 道路线都是solid, lineCap都是直角
1219 const lineDash = (w => [w, w + strokeWidth * 2])(4 * strokeWidth), lineCap= 'square';
1220 let strokeColorArray = this.hexToRgb(strokeColor);
1221 strokeColorArray && strokeColorArray.push(strokeOpacity);
1222 var stroke = new Style({
1223 stroke: new StrokeStyle({
1224 width: strokeWidth*0.5 || ZERO,
1225 color: strokeColorArray,
1226 lineCap,
1227 lineDash
1228 })
1229 });
1230
1231 const { strokeColor: outlineColor } = outlineStyle;
1232 let outlineColorArray = this.hexToRgb(outlineColor);
1233 // opacity使用style的透明度。保持两根线透明度一致
1234 outlineColorArray && outlineColorArray.push(strokeOpacity);
1235 var outlineStroke = new Style({
1236 stroke: new StrokeStyle({
1237 width: strokeWidth || ZERO,
1238 color: outlineColorArray,
1239 lineCap
1240 })
1241 });
1242 return [outlineStroke, stroke];
1243 }
1244}

Callers 2

StyleUtils2Spec.jsFile · 0.80
createVectorLayerMethod · 0.80

Calls 2

hexToRgbMethod · 0.95
pushMethod · 0.80

Tested by

no test coverage detected