Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.unproject(boundsQuad[j]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var leftBottom = geoBs[3];
var rightTop = geoBs[1];
var bounds = new Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = Util.cloneObject(fi.style);
feaSty = Util.cloneObject(Util.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
}
}
//压盖处理 -end
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.getCoordinateFromPixel([boundsQuad[j].x, boundsQuad[j].y]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var bounds = new Bounds(geoBs[3][0], geoBs[3][1], geoBs[1][0], [geoBs[1][1]]);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = CommonUtil.cloneObject(fi.style);
feaSty = CommonUtil.cloneObject(CommonUtil.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
calculateLabelBounds2(feature, loc) {
var labB, left, bottom, top, right;
var labelSize = feature.geometry.bsInfo;
var style = feature.style;
var locationPx = CommonUtil.cloneObject(loc);
//处理文字对齐
if (style.labelAlign && style.labelAlign !== "cm") {
switch (style.labelAlign) {
case "lt":
locationPx.x += labelSize.w / 2;
locationPx.y += labelSize.h / 2;
break;
case "lm":
locationPx.x += labelSize.w / 2;
break;
case "lb":
locationPx.x += labelSize.w / 2;
locationPx.y -= labelSize.h / 2;
break;
case "ct":
//背景(事件)-start
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.containerPointToLatLng(boundsQuad[j]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var leftBottom = geoBs[3];
var rightTop = geoBs[1];
var bounds = new Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = Util.cloneObject(fi.style);
feaSty = Util.cloneObject(Util.copyAttributes(styTmp, styleTemp));
fea = new GeometryVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
},
calculateLabelBounds2(feature, loc) {
var labB, left, bottom, top, right;
var labelSize = feature.geometry.bsInfo;
var style = feature.style;
var locationPx = Util.cloneObject(loc);
//处理文字对齐
if (style.labelAlign && style.labelAlign !== "cm") {
switch (style.labelAlign) {
case "lt":
locationPx.x += labelSize.w / 2;
locationPx.y += labelSize.h / 2;
break;
case "lm":
locationPx.x += labelSize.w / 2;
break;
case "lb":
locationPx.x += labelSize.w / 2;
locationPx.y -= labelSize.h / 2;
break;
case "ct":
//背景(事件)-start
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.unproject(boundsQuad[j]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var leftBottom = geoBs[3];
var rightTop = geoBs[1];
var bounds = new Bounds(leftBottom.lng, leftBottom.lat, rightTop.lng, rightTop.lat);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = Util.cloneObject(fi.style);
feaSty = Util.cloneObject(Util.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
}
//压盖处理 -end
//将标签像素范围转为地理范围
var geoBs = [];
for (let j = 0; j < quadlen - 1; j++) {
geoBs.push(map.getCoordinateFromPixel([boundsQuad[j].x, boundsQuad[j].y]));
}
//屏蔽有偏移性质的style属性,偏移量在算bounds时已经加入计算
var bounds = new Bounds(geoBs[3][0], geoBs[3][1], geoBs[1][0], [geoBs[1][1]]);
var center = bounds.getCenterLonLat();
var label = new GeoText(center.lon, center.lat, fi.attributes[this.themeField]);
label.calculateBounds();
styTmp = CommonUtil.cloneObject(fi.style);
feaSty = CommonUtil.cloneObject(CommonUtil.copyAttributes(styTmp, styleTemp));
fea = new FeatureVector(label, fi.attributes, feaSty);
//赋予id
fea.id = fi.id;
fea.fid = fi.fid;
feas.push(fea);
}
}
//返回最终要绘制的标签要素
return feas;
}
calculateLabelBounds2: function (feature, loc) {
var labB, left, bottom, top, right;
var labelSize = feature.geometry.bsInfo;
var style = feature.style;
var locationPx = Util.cloneObject(loc);
//处理文字对齐
if (style.labelAlign && style.labelAlign !== "cm") {
switch (style.labelAlign) {
case "lt":
locationPx.x += labelSize.w / 2;
locationPx.y += labelSize.h / 2;
break;
case "lm":
locationPx.x += labelSize.w / 2;
break;
case "lb":
locationPx.x += labelSize.w / 2;
locationPx.y -= labelSize.h / 2;
break;
case "ct":