2020-12-12 12:22:27
•
1053
百度地图 Label 文字不在红色框内
问题:百度地图中的LABEL显示文字不在框里。
原因:bootstrap中为label加了样式:max-width:100%;
解决办法:设置maxWidth:"none"
label.setStyle({borderRadius:"8px",padding:'2px',maxWidth:"none" });
完整代码为:
//显示marker的title,marker多的话可以注释掉 var label = new window.BMap.Label(markerArr[i].title, { offset : new window.BMap.Size(20, -10) }); label.setStyle({borderRadius:"3px",padding:'5px',maxWidth:"none" }); marker[i].setLabel(label);
百度地图 Label 文字不在红色框内