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

Method getCanvasWidth

src/openlayers/core/StyleUtils.js:847–860  ·  view source on GitHub ↗

* 获取自适应的宽度(如果没有超过最大宽度,就用文字的宽度) * @param lineWidths * @param maxWidth * @returns {number}

(lineWidths, maxWidth)

Source from the content-addressed store, hash-verified

845 * @returns {number}
846 */
847 static getCanvasWidth(lineWidths, maxWidth) {
848 let width = 0;
849 for (let i = 0; i < lineWidths.length; i++) {
850 let lineW = lineWidths[i];
851 if (lineW >= maxWidth) {
852 //有任何一行超过最大高度,就用最大高度
853 return maxWidth + doublePadding;
854 } else if (lineW > width) {
855 //自己换行,就要比较每行的最大宽度
856 width = lineW;
857 }
858 }
859 return width + doublePadding;
860 }
861 /**
862 * 绘制文字,解决换行问题
863 * @param text

Callers 2

drawRectMethod · 0.95
StyleUtils2Spec.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected