//文本标签;
function addLabel(point, txt) {
var opts = {
position: point,
offset: new BMap.Size(0, 20)//设置文本偏移量
}
var label = new BMap.Label(txt, opts); // 创建文本标注对象
label.setStyle({
color: "#FFF",
fontSize: "10px",
height: "24px",
lineHeight: "20px",
padding: "2px 5px",
border: "1px solid rgba(230, 0, 0, 0.7)",
background: "rgba(230, 0, 0, 0.7)",
fontWeight: "bold",
transform: 'translateX(-50%)',
fontFamily: "微软雅黑"
});
map.addOverlay(label);
}
解决方案
offset: new BMap.Size(0, 20)//设置文本偏移量
transform: 'translateX(-50%)',
Lockdatav Done!