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

Method getSVGStyle

src/openlayers/core/StyleUtils.js:1104–1126  ·  view source on GitHub ↗

* @function StyleUtils.getSVGStyle 获取svg的样式 * @param {Object} styleParams - 样式参数 * @returns {Promise }

(styleParams)

Source from the content-addressed store, hash-verified

1102 * @returns {Promise<ol.style.Style>}
1103 */
1104 static async getSVGStyle(styleParams) {
1105 let style, that = this;
1106 if (!that.svgDiv) {
1107 that.svgDiv = document.createElement('div');
1108 document.body.appendChild(that.svgDiv);
1109 }
1110 const { url, radius, offsetX, offsetY, fillOpacity, rotation } = styleParams;
1111 let anchor = this.getIconAnchor(offsetX, offsetY);
1112 await StyleUtils.getCanvasFromSVG(url, that.svgDiv, function (canvas) {
1113 style = new Style({
1114 image: new Icon({
1115 img: that.setColorToCanvas(canvas, styleParams),
1116 scale: 2 * radius / canvas.width,
1117 imgSize: [canvas.width, canvas.height],
1118 anchor: anchor || [0.5, 0.5],
1119 opacity: fillOpacity,
1120 anchorOrigin: 'bottom-right',
1121 rotation
1122 })
1123 });
1124 });
1125 return style;
1126 }
1127
1128 /**
1129 * @function StyleUtils.setColorToCanvas 将颜色,透明度等样式设置到canvas上

Callers 3

getOpenlayersStyleMethod · 0.95
StyleUtils2Spec.jsFile · 0.80
getUniqueStyleGroupMethod · 0.80

Calls 4

getIconAnchorMethod · 0.95
createElementMethod · 0.80
setColorToCanvasMethod · 0.80
getCanvasFromSVGMethod · 0.45

Tested by

no test coverage detected