处理网格缩放字体显示

This commit is contained in:
wanggeng 2022-09-27 11:57:31 +08:00
parent 260a7c7aeb
commit d0f8deb1a1
2 changed files with 4 additions and 19 deletions

View File

@ -296,9 +296,6 @@ BaiduMap.prototype.setLabelFontSize = function (size) {
for (var i = 0, label; label = this.labelArray[i++];) {
label.show();
label.setOffset(new BMap.Size(-label.content.length * size / 2, -size / 2));
label.setStyle({
fontSize: size + 'px'
})
}
}
// 获得Map对象
@ -356,16 +353,10 @@ BaiduMap.prototype.setDefaultConfig = function () {
// 缩放结束
self.map.addEventListener('zoomend', function (event) {
var zoom = this.getZoom();
if (zoom < 13) {
if (zoom < 15) {
self.setLabelFontSize(0);
} else if (zoom < 15) {
self.setLabelFontSize(12);
} else if (zoom < 16) {
self.setLabelFontSize(14);
} else if (zoom < 17) {
self.setLabelFontSize(16);
} else {
self.setLabelFontSize(18);
self.setLabelFontSize(12);
}
})
}

View File

@ -359,16 +359,10 @@ BaiduMap.prototype.setDefaultConfig = function () {
// 缩放结束
self.map.addEventListener('zoomend', function (event) {
var zoom = this.getZoom();
if (zoom < 13) {
if (zoom < 15) {
self.setLabelFontSize(0);
} else if (zoom < 15) {
self.setLabelFontSize(12);
} else if (zoom < 16) {
self.setLabelFontSize(14);
} else if (zoom < 17) {
self.setLabelFontSize(16);
} else {
self.setLabelFontSize(18);
self.setLabelFontSize(12);
}
})
}