The implementation idea is to set the style for the label. Let’s take a look at the specific method
var label = new BMap.Label("我是文字标注哦",{offset:new BMap.Size(20,-10)}); label.setStyle({ display:"none" //给label设置样式,任意的CSS都是可以的 }); marker.setLabel(label); marker.addEventListener("mouseover", function(){ label.setStyle({ //给label设置样式,任意的CSS都是可以的 display:"block" }); }); marker.addEventListener("mouseout", function(){ label.setStyle({ //给label设置样式,任意的CSS都是可以的 display:"none" }); });
The above is all the content shared with you in this article. I hope it will be helpful to everyone in learning javascript.