问题
添加标注的代码
let marker = new AMap.Marker({
icon:new AMap.Icon({
image: 'img/icon/'+item.mark,
size: new AMap.Size(22, 28), //图标所处区域大小
imageSize: new AMap.Size(22,28) //图标大小
}),
visible:false, //不能先设置隐藏 会导致 文本标签位置不对
position: [pos.y,pos.x],
anchor: 'bottom-center',
offset: new AMap.Pixel(-2,-2)//(-10, -30)s
});
marker.setLabel({
offset: new AMap.Pixel(0, -24), //设置文本标注偏移量
content: "<div class='info'>"+item.name+"</div>", //设置文本标注内容
direction: 'center' //设置文本标注方位
});
解决方法 用css
.amap-marker-label{
transform: translateX(-50%);
margin-left: 11px;
left: 0 !important;
}