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

Method getImageStyle

src/openlayers/core/StyleUtils.js:1152–1174  ·  view source on GitHub ↗

* @function StyleUtils.getImageStyle 获取图片样式 * @param {Object} styleParams - 样式参数 * @returns {Object} style对象

(styleParams)

Source from the content-addressed store, hash-verified

1150 * @returns {Object} style对象
1151 */
1152 static getImageStyle(styleParams) {
1153 let size = styleParams.imageInfo.size,
1154 scale = 2 * styleParams.radius / size.w;
1155 let imageInfo = styleParams.imageInfo;
1156 let imgDom = imageInfo.img;
1157 if (!imgDom || !imgDom.src) {
1158 imgDom = new Image();
1159 //要组装成完整的url
1160 imgDom.src = imageInfo.url;
1161 }
1162 const { offsetX, offsetY, rotation } = styleParams;
1163 let anchor = this.getIconAnchor(offsetX, offsetY);
1164 return new Style({
1165 image: new Icon({
1166 img: imgDom,
1167 scale,
1168 imgSize: [size.w, size.h],
1169 anchor: anchor || [0.5, 0.5],
1170 anchorOrigin: 'bottom-right',
1171 rotation
1172 })
1173 });
1174 }
1175 /**
1176 * @function StyleUtils.getRoadPath 获取道路样式
1177 * @param {Object} style - 样式参数

Callers 3

getOpenlayersStyleMethod · 0.95
StyleUtils2Spec.jsFile · 0.80
getUniqueStyleGroupMethod · 0.80

Calls 1

getIconAnchorMethod · 0.95

Tested by

no test coverage detected