@@ -25970,7 +25970,7 @@ var Label = function (_GeoFeature) {
2597025970 * @function mapboxgl.supermap.LabelThemeLayer.prototype.calculateLabelBounds
2597125971 * @description 获得标签要素的最终范围
2597225972 *
25973- * @param feature - {SuperMap.Feature.Vector> } 需要计算bounds的标签要素数。
25973+ * @param feature - {SuperMap.Feature.Vector} 需要计算bounds的标签要素数。
2597425974 * @param loc - {mapboxgl.Point} 标签位置
2597525975 *
2597625976 * @return {Array<Object>} 四边形节点数组。例如:[{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}]。
@@ -26012,7 +26012,7 @@ var Label = function (_GeoFeature) {
2601226012 * @function mapboxgl.supermap.LabelThemeLayer.prototype.calculateLabelBounds2
2601326013 * @description 获得标签要素的最终范围的另一种算法(通过记录下的标签宽高),提高计算bounds的效率。
2601426014 *
26015- * @param feature - {SuperMap.Feature.Vector> } 需要计算bounds的标签要素数。
26015+ * @param feature - {SuperMap.Feature.Vector} 需要计算bounds的标签要素数。
2601626016 * @param loc - {mapboxgl.Point} 标签位置
2601726017 *
2601826018 * @return {Array<Object>} 四边形节点数组。例如:[{"x":1,"y":1},{"x":3,"y":1},{"x":6,"y":4},{"x":2,"y":10},{"x":1,"y":1}]。
@@ -26127,40 +26127,42 @@ var Label = function (_GeoFeature) {
2612726127 canvas.globalAlpha = 0;
2612826128 canvas.lineWidth = 1;
2612926129
26130- canvas.fillStyle = style.fontColor;
26131- canvas.globalAlpha = style.fontOpacity || 1.0;
26130+ var ctx = canvas.getContext("2d");
26131+
26132+ ctx.fillStyle = style.fontColor;
26133+ ctx.globalAlpha = style.fontOpacity || 1.0;
2613226134 var fontStyle = [style.fontStyle ? style.fontStyle : "normal", "normal", style.fontWeight ? style.fontWeight : "normal", style.fontSize ? style.fontSize : "1em", style.fontFamily ? style.fontFamily : "sans-serif"].join(" ");
2613326135 var labelRows = style.label.split('\n');
2613426136 var numRows = labelRows.length;
2613526137 var vfactor, lineHeight, labelWidthTmp;
26136- if (canvas .fillText) {
26138+ if (ctx .fillText) {
2613726139 // HTML5
26138- canvas .font = fontStyle;
26139- canvas .textAlign = LABEL_ALIGN[style.labelAlign[0]] || "center";
26140- canvas .textBaseline = LABEL_ALIGN[style.labelAlign[1]] || "middle";
26140+ ctx .font = fontStyle;
26141+ ctx .textAlign = LABEL_ALIGN[style.labelAlign[0]] || "center";
26142+ ctx .textBaseline = LABEL_ALIGN[style.labelAlign[1]] || "middle";
2614126143 vfactor = LABEL_FACTOR[style.labelAlign[1]];
2614226144 if (vfactor == null) {
2614326145 vfactor = -.5;
2614426146 }
26145- lineHeight = canvas .measureText('Mg').height || canvas .measureText('xx').width;
26147+ lineHeight = ctx .measureText('Mg').height || ctx .measureText('xx').width;
2614626148 pt[1] += lineHeight * vfactor * (numRows - 1);
2614726149 for (var i = 0; i < numRows; i++) {
26148- labelWidthTmp = canvas .measureText(labelRows[i]).width;
26150+ labelWidthTmp = ctx .measureText(labelRows[i]).width;
2614926151 if (labelWidth < labelWidthTmp) {
2615026152 labelWidth = labelWidthTmp;
2615126153 }
2615226154 }
26153- } else if (canvas .mozDrawText) {
26155+ } else if (ctx .mozDrawText) {
2615426156 // Mozilla pre-Gecko1.9.1 (<FF3.1)
26155- canvas .mozTextStyle = fontStyle;
26157+ ctx .mozTextStyle = fontStyle;
2615626158 vfactor = LABEL_FACTOR[style.labelAlign[1]];
2615726159 if (vfactor == null) {
2615826160 vfactor = -.5;
2615926161 }
26160- lineHeight = canvas .mozMeasureText('xx');
26162+ lineHeight = ctx .mozMeasureText('xx');
2616126163 pt[1] += lineHeight * (1 + vfactor * numRows);
2616226164 for (var _i = 0; _i < numRows; _i++) {
26163- labelWidthTmp = canvas .measureText(labelRows[_i]).width;
26165+ labelWidthTmp = ctx .measureText(labelRows[_i]).width;
2616426166 if (labelWidth < labelWidthTmp) {
2616526167 labelWidth = labelWidthTmp;
2616626168 }
@@ -59884,24 +59886,13 @@ var Image = function (_ShapeParameters) {
5988459886 _this.x = x;
5988559887 _this.y = y;
5988659888 _this.image = image;
59887- if (_this.width) {
59888- _this.width = width;
59889- }
59890- if (_this.height) {
59891- _this.height = width;
59892- }
59893- if (_this.sx) {
59894- _this.sx = width;
59895- }
59896- if (_this.sy) {
59897- _this.sy = width;
59898- }
59899- if (_this.sWidth) {
59900- _this.sWidth = width;
59901- }
59902- if (_this.sHeight) {
59903- _this.sHeight = width;
59904- }
59889+
59890+ _this.width = width;
59891+ _this.height = height;
59892+ _this.sx = sx;
59893+ _this.sy = sy;
59894+ _this.sWidth = sWidth;
59895+ _this.sHeight = sHeight;
5990559896 return _this;
5990659897 }
5990759898
0 commit comments